Skip to content

Commit

Permalink
Small tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
robdmoore committed Jul 17, 2013
1 parent c117b93 commit 9baf4ac
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion ReliableDbProvider.Tests/Config/DbTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class DbTestBase<T>
{
protected abstract string ConnectionString { get; }

public virtual Context GetContext()
protected virtual Context GetContext()
{
var provider = GetProvider();
var connection = provider.CreateConnection();
Expand Down
51 changes: 25 additions & 26 deletions ReliableDbProvider.Tests/MassiveTests.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
using System.Dynamic;
using System.Configuration;
using System.Data.Entity;
using System.Dynamic;
using System.Linq;
using Massive;
using NUnit.Framework;
using ReliableDbProvider.SqlAzureWithTimeoutRetries;
using ReliableDbProvider.Tests.Config;
using ReliableDbProvider.Tests.SqlExpress;

namespace ReliableDbProvider.Tests
{
class MassiveTests
class MassiveTests : PooledDbTestBase<SqlExpressProvider>
{
[TestFixtureSetUp]
public void FixtureSetup()
{
EnsureDatabaseExists();
}

[Test]
public void Perform_select()
{
AssureDatabaseExists();

dynamic table = GetMassive();
dynamic table = GetDatabaseModel();

Assert.DoesNotThrow(() =>
{
var user = table.Single(Id: 0);
});
Assert.DoesNotThrow(() => table.Single(Id: 0));
}

[Test]
public void Insert_and_select()
{
AssureDatabaseExists();

dynamic table = GetMassive();

dynamic user = new ExpandoObject();
user.Name = "Massive User";
table.Insert(user);

var userId = user.ID;
dynamic table = GetDatabaseModel();
dynamic userProperty = new ExpandoObject();
userProperty.Name = "Massive User";

var dbUser = table.Single(Id: userId);
table.Insert(userProperty);

Assert.That(dbUser.Name, Is.EqualTo("Massive User"));
var dbUser = table.Single(Id: userProperty.Id);
Assert.That(dbUser.Name, Is.EqualTo(userProperty.Name));
}

private static DynamicModel GetMassive()
private static DynamicModel GetDatabaseModel()
{
// Massive doesn't work with table "User" so let's user UserProperty instead. (Massive doesn't transform User to [User]).
return new DynamicModel("ReliableDatabase", tableName: "UserProperty", primaryKeyField: "Id");
}

private void AssureDatabaseExists()
private void EnsureDatabaseExists()
{
var provider = new SqlExpressProviderShould();
using (var context = provider.GetContext())
using (var context = GetContext())
{
var user = context.Users.SingleOrDefault(u => u.Id == -1);
context.Database.Initialize(false);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ReliableDbProvider.Tests/SqlExpressProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace ReliableDbProvider.Tests
{
class SqlExpressProviderViaConnectionStringNameShould : SqlExpressProviderShould
{
public override Context GetContext()
protected override Context GetContext()
{
return new Context("ReliableDatabase");
}
Expand Down

0 comments on commit 9baf4ac

Please sign in to comment.