当前位置: 首页>>代码示例>>C#>>正文


C# Ado.MockDatabase类代码示例

本文整理汇总了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]);
 }
开发者ID:christianblunden,项目名称:Simple.Data,代码行数:8,代码来源:DatabaseTest.cs

示例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]);
 }
开发者ID:JorgeGamba,项目名称:Simple.Data,代码行数:8,代码来源:SchemaQualifiedTableTest.cs

示例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]);
 }
开发者ID:ciriarte,项目名称:Simple.Data,代码行数:8,代码来源:SchemaQualifiedTableTest.cs

示例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]);
 }
开发者ID:fzawada,项目名称:Simple.Data,代码行数:8,代码来源:DatabaseTest.cs

示例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]);
 }
开发者ID:reverentgeek,项目名称:Simple.Data,代码行数:9,代码来源:RangeAndArrayFindTest.cs

示例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());
 }
开发者ID:JorgeGamba,项目名称:Simple.Data,代码行数:9,代码来源:ProcedureTest.cs

示例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)));
 }
开发者ID:darrencauthon,项目名称:Simple.Data,代码行数:9,代码来源:ProcedureTest.cs

示例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());
 }
开发者ID:darrencauthon,项目名称:Simple.Data,代码行数:9,代码来源:ProcedureTest.cs

示例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]);
 }
开发者ID:robashton,项目名称:Simple.Data,代码行数:9,代码来源:RangeAndArrayFindTest.cs

示例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]);
 }
开发者ID:JorgeGamba,项目名称:Simple.Data,代码行数:10,代码来源:RangeAndArrayFindTest.cs

示例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]);
 }
开发者ID:robashton,项目名称:Simple.Data,代码行数:10,代码来源:RangeAndArrayFindTest.cs

示例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();
        }
开发者ID:vansha,项目名称:Simple.Data,代码行数:11,代码来源:DatabaseIntegrationContext.cs

示例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)));
 }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:11,代码来源:SchemaQualifiedTableTest.cs

示例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]);
 }
开发者ID:reverentgeek,项目名称:Simple.Data,代码行数:11,代码来源:TransactionTest.cs

示例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]);
 }
开发者ID:reverentgeek,项目名称:Simple.Data,代码行数:11,代码来源:TransactionTest.cs


注:本文中的Simple.Data.Mocking.Ado.MockDatabase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。