public void CreateProduct_saves_a_Product_via_repository() { //Arrange var product = new core.Models.Product { Name = "TestMockProduct", Price = 100.00M, Description = "Mock Text Product", DeliveryPrice = 10.00M, Id = new Guid() }; //Act _productService.CreateProduct(product); var count = _mockContext.Products.Local.Count; //Assert Assert.AreEqual(count, 3); }
public void Create_saves_a_Product_via_context() { //Arrange var repository = new ProductRepository(_mapper, _mockContext, _logging); var product = new core.Models.Product { Name = "TestMockProduct", Price = 100.00M, Description = "Mock Text Product", DeliveryPrice = 10.00M, Id = new Guid() }; //Act repository.Create(product); var count = _mockContext.Products.Local.Count; //Assert Assert.AreEqual(count, 3); }
public void Create_saves_a_Product_via_service() { //Arrange var product = new core.Models.Product { Name = "TestMockProduct", Price = 100.00M, Description = "Mock Text Product", DeliveryPrice = 10.00M, Id = new Guid() }; //Act _Controller.Create(product); var products = _Controller.Get(); //Assert Assert.IsNotNull(products); Assert.AreEqual(products.Items.Count, 3); }
public void UpdateProduct_update_specified_Product_via_repository() { //Arrange var productToUpdate = new core.Models.Product { Id = new Guid("de1287c0-4b15-4a7b-9d8a-dd21b3cafec3"), Name = "Apple iPhone 6S Test Mock", Description = "Newest mobile product from Apple.", Price = 1299.99M, DeliveryPrice = 20M }; //Act _productService.UpdateProduct(productToUpdate); var updatedProduct = _productService.GetProductById(new Guid("de1287c0-4b15-4a7b-9d8a-dd21b3cafec3")); //Assert Assert.IsNotNull(updatedProduct); Assert.AreEqual(updatedProduct.Name, "Apple iPhone 6S Test Mock"); Assert.AreEqual(updatedProduct.Name, productToUpdate.Name); Assert.AreEqual(updatedProduct.DeliveryPrice, productToUpdate.DeliveryPrice); }
public void Update_update_specified_Product_via_context() { //Arrange var repository = new ProductRepository(_mapper, _mockContext, _logging); var productToUpdate = new core.Models.Product { Id = new Guid("de1287c0-4b15-4a7b-9d8a-dd21b3cafec3"), Name = "Apple iPhone 6S Test Mock", Description = "Newest mobile product from Apple.", Price = 1299.99M, DeliveryPrice = 20M }; //Act repository.Update(productToUpdate); var updatedProduct = repository.GetById(new Guid("de1287c0-4b15-4a7b-9d8a-dd21b3cafec3")); //Assert Assert.IsNotNull(updatedProduct); Assert.AreEqual(updatedProduct.Name, "Apple iPhone 6S Test Mock"); Assert.AreEqual(updatedProduct.Name, productToUpdate.Name); Assert.AreEqual(updatedProduct.DeliveryPrice, productToUpdate.DeliveryPrice); }