本文整理汇总了C#中Simple.Data.Mocking.Ado.MockDatabase类的典型用法代码示例。如果您正苦于以下问题:C# MockDatabase类的具体用法?C# MockDatabase怎么用?C# MockDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockDatabase类属于Simple.Data.Mocking.Ado命名空间,在下文中一共展示了MockDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFindEqualWithInt32
public void TestFindEqualWithInt32()
{
var mockDatabase = new MockDatabase();
dynamic database = CreateDatabase(mockDatabase);
database.Users.Find(database.Users.Id == 1);
Assert.AreEqual("select [users].* from [users] where [users].[id] = @p1".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual(1, mockDatabase.Parameters[0]);
}
示例2: TestFindLessThanOrEqualWithInt32
public void TestFindLessThanOrEqualWithInt32()
{
var mockDatabase = new MockDatabase();
dynamic database = CreateDatabase(mockDatabase);
database.foo.Users.Find(database.foo.Users.Id <= 1);
Assert.AreEqual("select " + usersColumns + " from [foo].[Users] where [foo].[Users].[Id] <= @p1".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual(1, mockDatabase.Parameters[0]);
}
示例3: TestFindNotEqualWithInt32
public void TestFindNotEqualWithInt32()
{
var mockDatabase = new MockDatabase();
dynamic database = CreateDatabase(mockDatabase);
database.foo.Users.Find(database.foo.Users.Id != 1);
Assert.AreEqual("select [foo].[Users].* from [foo].[Users] where [foo].[Users].[Id] != @p1".ToLowerInvariant().ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual(1, mockDatabase.Parameters[0]);
}
示例4: TestFindLessThanWithInt32
public void TestFindLessThanWithInt32()
{
var mockDatabase = new MockDatabase();
dynamic database = CreateDatabase(mockDatabase);
database.Users.Find(database.Users.Id < 1);
Assert.AreEqual("select [dbo].[Users].* from [dbo].[Users] where [dbo].[Users].[Id] < @p1".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual(1, mockDatabase.Parameters[0]);
}
示例5: TestFindByWithDateRange
public void TestFindByWithDateRange()
{
var mockDatabase = new MockDatabase();
dynamic database = CreateDatabase(mockDatabase);
database.Users.FindAllByJoinDate("2011-01-01".to("2011-01-31")).ToList();
Assert.AreEqual("select [dbo].[users].[id],[dbo].[users].[name],[dbo].[users].[password],[dbo].[users].[age],[dbo].[users].[joindate] from [dbo].[users] where [dbo].[users].[joindate] between @p1_start and @p1_end".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual(new DateTime(2011,1,1), mockDatabase.Parameters[0]);
Assert.AreEqual(new DateTime(2011,1,31), mockDatabase.Parameters[1]);
}
示例6: CallingMethodOnObjectInDatabase_Should_CallProcedure
public void CallingMethodOnObjectInDatabase_Should_CallProcedure()
{
var mockDatabase = new MockDatabase();
var db = CreateDatabase(mockDatabase);
db.foo.ProcedureInAnotherSchema();
Assert.IsNotNull(mockDatabase.Sql);
Assert.AreEqual("[foo].[ProcedureInAnotherSchema]".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual(0, mockDatabase.Parameters.Count());
}
示例7: CreateDatabase
static dynamic CreateDatabase(MockDatabase mockDatabase)
{
var mockSchemaProvider = new MockSchemaProvider();
mockSchemaProvider.SetProcedures(new[] { "dbo", "ProcedureWithParameters" },
new[] { "dbo", "ProcedureWithoutParameters"});
mockSchemaProvider.SetParameters(new[] { "dbo", "ProcedureWithParameters", "@One" },
new[] { "dbo", "ProcedureWithParameters", "@Two" });
return new Database(new AdoAdapter(new MockConnectionProvider(new MockDbConnection(mockDatabase), mockSchemaProvider)));
}
示例8: CallingMethodOnDatabase_Should_CallProcedure
public void CallingMethodOnDatabase_Should_CallProcedure()
{
var mockDatabase = new MockDatabase();
var db = CreateDatabase(mockDatabase);
db.ProcedureWithoutParameters();
Assert.IsNotNull(mockDatabase.Sql);
Assert.AreEqual("[ProcedureWithoutParameters]".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual(0, mockDatabase.Parameters.Count());
}
示例9: TestFindByWithIntRange
public void TestFindByWithIntRange()
{
var mockDatabase = new MockDatabase();
dynamic database = CreateDatabase(mockDatabase);
database.Users.FindAllById(1.to(10)).ToList();
Assert.AreEqual("select [dbo].[users].* from [dbo].[users] where [dbo].[users].[id] between @p1 and @p2".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual(1, mockDatabase.Parameters[0]);
Assert.AreEqual(10, mockDatabase.Parameters[1]);
}
示例10: TestQueryWithNotEqualIntArray
public void TestQueryWithNotEqualIntArray()
{
var mockDatabase = new MockDatabase();
dynamic database = CreateDatabase(mockDatabase);
database.Users.Query().Where(database.Users.Id != new[] { 1, 2, 3 }).ToList();
Assert.AreEqual("select [dbo].[users].[id],[dbo].[users].[name],[dbo].[users].[password],[dbo].[users].[age],[dbo].[users].[joindate] from [dbo].[users] where [dbo].[users].[id] not in (@p1_0,@p1_1,@p1_2)".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual(1, mockDatabase.Parameters[0]);
Assert.AreEqual(2, mockDatabase.Parameters[1]);
Assert.AreEqual(3, mockDatabase.Parameters[2]);
}
示例11: TestFindByWithIntArray
public void TestFindByWithIntArray()
{
var mockDatabase = new MockDatabase();
dynamic database = CreateDatabase(mockDatabase);
database.Users.FindAllById(new[] { 1, 2, 3 }).ToList();
Assert.AreEqual("select [dbo].[users].* from [dbo].[users] where [dbo].[users].[id] in (@p1,@p2,@p3)".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual(1, mockDatabase.Parameters[0]);
Assert.AreEqual(2, mockDatabase.Parameters[1]);
Assert.AreEqual(3, mockDatabase.Parameters[2]);
}
示例12: CreateDatabase
Database CreateDatabase(MockDatabase mockDatabase)
{
var mockSchemaProvider = new MockSchemaProvider();
SetSchema(mockSchemaProvider);
var adapter = MockHelper.CreateMockAdoAdapter(
new MockConnectionProvider(new MockDbConnection(mockDatabase), mockSchemaProvider));
MockHelper.UseMockAdapter(adapter);
return Database.Open();
}
示例13: CreateDatabase
static Database CreateDatabase(MockDatabase mockDatabase)
{
var mockSchemaProvider = new MockSchemaProvider();
mockSchemaProvider.SetTables(new[] { "foo", "Users", "BASE TABLE" });
mockSchemaProvider.SetColumns(new[] { "foo", "Users", "Id" },
new[] { "foo", "Users", "Name" },
new[] { "foo", "Users", "Password" },
new[] { "foo", "Users", "Age" });
mockSchemaProvider.SetPrimaryKeys(new object[] { "foo", "Users", "Id", 0 });
return new Database(new AdoAdapter(new MockConnectionProvider(new MockDbConnection(mockDatabase), mockSchemaProvider)));
}
示例14: TestFindByDynamicSingleColumn
public void TestFindByDynamicSingleColumn()
{
var mockDatabase = new MockDatabase();
dynamic database = CreateDatabase(mockDatabase);
using (var transaction = database.BeginTransaction())
{
transaction.Users.FindByName("Foo");
}
Assert.AreEqual("select [dbo].[Users].* from [dbo].[Users] where [dbo].[Users].[name] = @p1".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual("Foo", mockDatabase.Parameters[0]);
}
示例15: TestFindEqualWithInt32
public void TestFindEqualWithInt32()
{
var mockDatabase = new MockDatabase();
dynamic database = CreateDatabase(mockDatabase);
using (var transaction = database.BeginTransaction())
{
transaction.Users.Find(database.Users.Id == 1);
}
Assert.AreEqual("select [dbo].[users].* from [dbo].[users] where [dbo].[users].[id] = @p1".ToLowerInvariant(), mockDatabase.Sql.ToLowerInvariant());
Assert.AreEqual(1, mockDatabase.Parameters[0]);
}