public void should_execute_multi_mapping_one_to_many_relation_select_statement() { var inMemoryDatabase = new InMemoryDatabase(); inMemoryDatabase.Insert <Product>(new List <Product> { new Product("987", "123") }); inMemoryDatabase.Insert <ProductModel>(new List <ProductModel> { new ProductModel("987", "123") }); var mockRepo = new MockRepository(MockBehavior.Default); var loggerMock = mockRepo.Create <ILogger>(); loggerMock.Setup(a => a.WriteLine(It.IsAny <string>())) .Callback <string>(msg => Assert.IsTrue( msg.Contains("SELECT * FROM ProductModel PM INNER JOIN Product P ON PM.ProductModelID = P.ProductModelID") || msg.Contains("Retrieved 1 ProductModel entities") || msg.Contains("The first Product Model with name has 1 products") )); var multiMappingOneToManyRelationSelectStatement = new MultiMappingOneToManyRelationSelectStatement(); multiMappingOneToManyRelationSelectStatement.Execute(inMemoryDatabase.OpenConnection(), loggerMock.Object); }
public void should_execute_simple_select_with_dynamic_entities_statement() { var inMemoryDatabase = new InMemoryDatabase(); inMemoryDatabase.Insert <Person>(new List <Person> { new Person() }); var mockRepo = new MockRepository(MockBehavior.Default); var loggerMock = mockRepo.Create <ILogger>(); loggerMock.Setup(a => a.WriteLine(It.IsAny <string>())) .Callback <string>(msg => Assert.IsTrue(msg.Contains("SELECT FirstName,MiddleName,LastName FROM Person"))); var simpleSelectStatementWithDynamicEntities = new SimpleSelectStatementWithDynamicEntities(); simpleSelectStatementWithDynamicEntities.Execute(inMemoryDatabase.OpenConnection(), loggerMock.Object); }
public void should_execute_parameterized_select_statement() { var inMemoryDatabase = new InMemoryDatabase(); inMemoryDatabase.Insert <Product>(new List <Product> { new Product() }); var mockRepo = new MockRepository(MockBehavior.Default); var loggerMock = mockRepo.Create <ILogger>(); loggerMock.Setup(a => a.WriteLine(It.IsAny <string>())) .Callback <string>(msg => Assert.IsTrue(msg.Contains("SELECT * FROM Product where ProductId = @Id"))); var parameterizedSelectStatement = new ParameterizedSelectStatement(); parameterizedSelectStatement.Execute(inMemoryDatabase.OpenConnection(), loggerMock.Object); }
public void should_execute_simple_select_statement() { var inMemoryDatabase = new InMemoryDatabase(); inMemoryDatabase.Insert <Person>(new List <Person> { new Person() }); var mockRepo = new MockRepository(MockBehavior.Default); var loggerMock = mockRepo.Create <ILogger>(); loggerMock.Setup(a => a.WriteLine(It.IsAny <string>())) .Callback <string>(msg => Assert.IsTrue(msg.Contains("SELECT * FROM PERSON"))); var simpleSelectStatement = new SimpleSelectStatement(); simpleSelectStatement.Execute(inMemoryDatabase.OpenConnection(), loggerMock.Object); }
public void should_execute_multiple_queries_statement() { var inMemoryDatabase = new InMemoryDatabase(); inMemoryDatabase.Insert <Product>(new List <Product> { new Product() { ProductID = "707" } }); inMemoryDatabase.Insert <ProductCostHistory>(new List <ProductCostHistory> { new ProductCostHistory() }); inMemoryDatabase.Insert <ProductInventory>(new List <ProductInventory> { new ProductInventory() }); var mockRepo = new MockRepository(MockBehavior.Default); var loggerMock = mockRepo.Create <ILogger>(); loggerMock.Setup(a => a.WriteLine(It.IsAny <string>())) .Callback <string>(msg => Assert.IsTrue( msg.Contains(@"SELECT * from Product where ProductId = @Id;") || msg.Contains(@"Retrived one product with id 707") || msg.Contains(@"Retrieved 0 history for that Product") || msg.Contains(@"Retrieved 0 inventory for that Product") )); var multipleQueries = new MultipleQueries(); multipleQueries.Execute(inMemoryDatabase.OpenConnection(), loggerMock.Object); }