當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。