public void SelectAllProductsDto() { using (IDbConnection dbConnection = new SqliteConnectionFactory().Create()) { var product1 = new ProductDto { Name = "Product #1" }; dbConnection.Execute(new InsertProduct().Query(product1)); var product2 = new ProductDto { Name = "Product #2" }; dbConnection.Execute(new InsertProduct().Query(product2)); var product3 = new ProductDto { Name = "Product #3" }; dbConnection.Execute(new InsertProduct().Query(product3)); QueryObject all = new SelectProduct().All(); IEnumerable <ProductDto> productDtos = dbConnection.Query <ProductDto>(all); Assert.AreEqual(3, productDtos.Count()); } }
public void SelectAllProductsDto() { using (IDbConnection dbConnection = new SqliteConnectionFactory().Create()) { var product1 = new ProductDto {Name = "Product #1"}; dbConnection.Execute(new InsertProduct().Query(product1)); var product2 = new ProductDto {Name = "Product #2"}; dbConnection.Execute(new InsertProduct().Query(product2)); var product3 = new ProductDto {Name = "Product #3"}; dbConnection.Execute(new InsertProduct().Query(product3)); QueryObject all = new SelectProduct().All(); IEnumerable<ProductDto> productDtos = dbConnection.Query<ProductDto>(all); Assert.AreEqual(3, productDtos.Count()); } }
public void SelectProductDtoById() { using (IDbConnection dbConnection = new SqliteConnectionFactory().Create()) { var product1 = new ProductDto {Name = "Product #1"}; dbConnection.Execute(new InsertProduct().Query(product1)); QueryObject byId = new SelectProduct().ById(1); ProductDto productDto = dbConnection.Query<ProductDto>(byId).SingleOrDefault(); Assert.AreEqual(1, productDto.Id); Assert.AreEqual("Product #1", productDto.Name); } }
public void SelectProductDtoById() { using (IDbConnection dbConnection = new SqliteConnectionFactory().Create()) { var product1 = new ProductDto { Name = "Product #1" }; dbConnection.Execute(new InsertProduct().Query(product1)); QueryObject byId = new SelectProduct().ById(1); ProductDto productDto = dbConnection.Query <ProductDto>(byId).SingleOrDefault(); Assert.AreEqual(1, productDto.Id); Assert.AreEqual("Product #1", productDto.Name); } }
public void UpdateProductName() { using (IDbConnection dbConnection = new SqliteConnectionFactory().Create()) { var insertProduct = new InsertProduct(); var product = new ProductDto {Name = "Product Name"}; product.Id = (int) dbConnection.Query<Int64>(insertProduct.Query(product)).Single(); var updateProduct = new UpdateProduct(); dbConnection.Execute(updateProduct.NameForAllProducts("new name")); var selectProduct = new SelectProduct(); ProductDto result = dbConnection.Query<ProductDto>(selectProduct.ById(product.Id)).Single(); StringAssert.AreEqualIgnoringCase("new name", result.Name); } }
public void UpdateProductName() { using (IDbConnection dbConnection = new SqliteConnectionFactory().Create()) { var insertProduct = new InsertProduct(); var product = new ProductDto { Name = "Product Name" }; product.Id = (int)dbConnection.Query <Int64>(insertProduct.Query(product)).Single(); var updateProduct = new UpdateProduct(); dbConnection.Execute(updateProduct.NameForAllProducts("new name")); var selectProduct = new SelectProduct(); ProductDto result = dbConnection.Query <ProductDto>(selectProduct.ById(product.Id)).Single(); StringAssert.AreEqualIgnoringCase("new name", result.Name); } }