public async void Test_Delete_Sale_Service() { var fakeContext = new FakeContext("Delete_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var response = await service.Delete(1); Assert.Equal("{ Message = Venda cancelada com sucesso. }", response.ToString()); } }
public async void Test_Return_Message_When_Wrong_Id_Update_Sale_Service() { var fakeContext = new FakeContext("Return_Message_When_Wrong_Id_Update_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var currentSale = service.GetById(1); var response = await service.Update(2, currentSale); Assert.Equal("{ Message = Não é possível alterar o produto vendido. " + "É preciso cancelar a venda e criar uma nova venda. }", response.ToString()); } }
public async void Test_Return_Message_When_Wrong_Id_Delete_Sale_Service() { var fakeContext = new FakeContext("Return_Message_When_Wrong_Id_Delete_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var response = await service.Delete(6); Assert.Null(response); } }
public async void Test_Return_Message_When_Quantity_Larger_Than_Stock_Create_Sale_Service() { var fakeContext = new FakeContext("Return_Message_When_Quantity_Larger_Than_Stock_Create_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var sale = new Sale(); sale.ProductId = 1; sale.Quantity = 300; var newSale = await service.Create(sale); Assert.Equal("{ Message = Quantidade indisponível no estoque. }", newSale.ToString()); } }
public void Test_GetAll_Sale_Service() { var fakeContext = new FakeContext("GetAll_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var test = service.GetAll(); var countSales = context.Sales.Count(); Assert.Equal(countSales, test.Count()); Assert.Equal(context.Sales.ToList(), test); Assert.IsType <SaleRepository>(repository); Assert.IsType <ProductRepository>(productRepository); Assert.IsType <Mock <IUpdateProduct> >(updateMock); Assert.IsType <Mock <IMessageHandler> >(messageMock); } }
public void Test_Return_Message_When_Product_NotFound_Create_Sale_Service() { var fakeContext = new FakeContext("Return_Message_When_Product_NotFound_Create_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var sale = new Sale(); var newSale = service.Create(sale); Assert.Equal("{ Message = Produto não encontrado. }", newSale.Result.ToString()); } }
public void Test_ProductValidator_Same_Name_Or_Sku_Warehouse() { var fakeContext = new FakeContext("Test_ProductValidator_Same_Name_Or_Sku_Warehouse"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { validator = new ProductValidator(context); var repository = new ProductRepository(context); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Product>())) .Returns(Task.CompletedTask); var service = new ProductService(repository, messageMock.Object); var product = new Product(); product.Sku = "1001"; product.Name = "Product 1"; product.Price = 15M; product.Quantity = 150; service.Create(product); var result = validator.TestValidate(product); result.ShouldHaveAnyValidationError(); Assert.Equal("Produto já cadastrado.", result.Errors[0].ErrorMessage); } }
public void Test_GetById_Products_Warehouse_Service(int id) { var fakeContext = new FakeContext("GetByIdProducts_Warehouse_Service"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var expected = fakeContext.GetFakeData <Product>().Find(x => x.Id == id); var repository = new ProductRepository(context); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Product>())) .Returns(Task.CompletedTask); var service = new ProductService(repository, messageMock.Object); var actual = service.GetById(id); Assert.IsType <ProductRepository>(repository); Assert.IsType <ProductService>(service); Assert.IsType <Product>(actual); Assert.Equal(expected.CreatedAt, actual.CreatedAt); Assert.Equal(expected.UpdatedAt, actual.UpdatedAt); Assert.Equal(expected.Id, actual.Id); Assert.Equal(expected.Sku, actual.Sku); Assert.Equal(expected.Name, actual.Name); Assert.Equal(expected.Price, actual.Price); Assert.Equal(expected.Quantity, actual.Quantity); } }
public void Test_GetById_Sale_Service(int id) { var fakeContext = new FakeContext("GetById_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var test = service.GetById(id); Assert.Equal(id, test.Id); Assert.NotNull(test); Assert.IsType <Sale>(test); Assert.Equal(repository.GetById(id).Quantity, service.GetById(id).Quantity); } }
public void Test_SaleController_GetById(int id) { var fakeContext = new FakeContext("SaleController_GetById"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var controller = new SaleController(service); var response = controller.GetById(id); var okResult = response as OkObjectResult; var resultValue = okResult.Value; Assert.NotNull(okResult); Assert.Equal(200, okResult.StatusCode); Assert.Equal(repository.GetById(id), okResult.Value); Assert.IsType <Sale>(resultValue); } }
public void Generic_Create_Service() { var fakeContext = new FakeContext("Generic_Create_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new GenericRepository <Product>(context); var service = new GenericService <Product>(repository); var product = new Product("1000", "Product 1", 10M, 15, new DateTime(2019, 03, 10), new DateTime(2020, 7, 14)); var response = service.Create(product); Assert.Equal(6, service.GetAll().Count()); Assert.Equal("{ Message = Produto cadastrado com sucesso. }", response.ToString()); Assert.Equal("1000", service.GetById(6).Sku); Assert.Equal("Product 1", service.GetById(6).Name); Assert.Equal(10M, service.GetById(6).Price); Assert.Equal(15, service.GetById(6).Quantity); Assert.Equal(2019, service.GetById(6).CreatedAt.Year); } }
public void Test_Create_Product_Warehouse() { var fakeContext = new FakeContext("Create_Products_Warehouse"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var fakeProduct = new Product(); fakeProduct.Sku = "3000"; fakeProduct.Name = "Product test"; fakeProduct.Price = 120M; fakeProduct.Quantity = 100; fakeProduct.CreatedAt = new DateTime(2020, 02, 22); fakeProduct.UpdatedAt = new DateTime(2020, 08, 15); var repository = new GenericRepository <Product>(context); repository.Create(fakeProduct); var createdProduct = repository.GetById(6); Assert.IsType <Product>(createdProduct); Assert.NotEqual(0, createdProduct.Id); Assert.Equal("Product test", createdProduct.Name); Assert.Equal("3000", createdProduct.Sku); Assert.Equal(120M, createdProduct.Price); Assert.Equal(100, createdProduct.Quantity); Assert.Equal(new DateTime(2020, 02, 22), createdProduct.CreatedAt); Assert.Equal(new DateTime(2020, 08, 15), createdProduct.UpdatedAt); Assert.Equal(6, createdProduct.Id); } }
public void Test_GetAll_Products_NonZero_Quantity_Sale_Service() { var fakeContext = new FakeContext("GetAllProducts_NonZero_Quantity_Sale_Service"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var testProduct = new Product("1000", "Product 1", 10M, 0, new DateTime(2019, 03, 10), new DateTime(2020, 7, 14)); var repository = new ProductRepository(context); var service = new ProductService(repository); var edu = service.Create(testProduct); Assert.Equal(6, context.Products.Count()); Assert.Equal(5, service.GetAll().Count()); Assert.IsType <ProductRepository>(repository); Assert.IsType <ProductService>(service); foreach (var item in service.GetAll()) { Assert.NotEqual(0, item.Quantity); } } }
public void Test_GetById_Products_Sale_Service(int id) { var fakeContext = new FakeContext("GetByIdProducts_Sale_Service"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var expected = fakeContext.GetFakeData <Product>().Find(x => x.Id == id); var repository = new ProductRepository(context); var service = new ProductService(repository); var actual = service.GetById(id); Assert.IsType <ProductRepository>(repository); Assert.IsType <ProductService>(service); Assert.IsType <Product>(actual); Assert.Equal(expected.CreatedAt, actual.CreatedAt); Assert.Equal(expected.UpdatedAt, actual.UpdatedAt); Assert.Equal(expected.Id, actual.Id); Assert.Equal(expected.Sku, actual.Sku); Assert.Equal(expected.Name, actual.Name); Assert.Equal(expected.Price, actual.Price); Assert.Equal(expected.Quantity, actual.Quantity); } }
public void Test_GetAllProducts_NonZero_Quantity_Warehouse_Service() { var fakeContext = new FakeContext("GetAllProducts_NonZero_Quantity_Warehouse_Service"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var fakeProduct = new Product(); fakeProduct.Sku = "3000"; fakeProduct.Name = "Product test"; fakeProduct.Price = 120M; fakeProduct.Quantity = 100; fakeProduct.CreatedAt = new DateTime(2020, 02, 22); fakeProduct.UpdatedAt = new DateTime(2020, 08, 15); var repository = new ProductRepository(context); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Product>())) .Returns(Task.CompletedTask); var service = new ProductService(repository, messageMock.Object); var edu = service.Create(fakeProduct); Assert.Equal(6, context.Products.Count()); Assert.IsType <ProductRepository>(repository); Assert.IsType <ProductService>(service); foreach (var item in service.GetAll()) { Assert.NotEqual(0, item.Quantity); } } }
public async void Test_Return_Message_When_NotFound_SaleController_Delete() { var fakeContext = new FakeContext("Test_Return_Message_When_NotFound_SaleController_Delete"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var controller = new SaleController(service); var response = await controller.Delete(10); var okResult = response as NotFoundObjectResult; Assert.NotNull(okResult); Assert.Equal(404, okResult.StatusCode); } }
public void Test_Create_Product_Sale_Service() { var fakeContext = new FakeContext("Create_Products_Sale_Service"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var fakeProduct = new Product(); fakeProduct.Sku = "3000"; fakeProduct.Name = "Product test"; fakeProduct.Price = 120M; fakeProduct.Quantity = 100; fakeProduct.CreatedAt = new DateTime(2020, 02, 22); fakeProduct.UpdatedAt = new DateTime(2020, 08, 15); var repository = new ProductRepository(context); var service = new ProductService(repository); service.Create(fakeProduct); var createdProduct = service.GetById(6); Assert.IsType <Product>(createdProduct); Assert.Equal(6, repository.GetAll().Count()); Assert.Equal(6, service.GetAll().Count()); Assert.NotEqual(0, createdProduct.Id); Assert.Equal("Product test", createdProduct.Name); Assert.Equal("3000", createdProduct.Sku); Assert.Equal(120M, createdProduct.Price); Assert.Equal(100, createdProduct.Quantity); Assert.Equal(6, createdProduct.Id); } }
public void Test_Create_Sale() { var fakeContext = new FakeContext("Create_Sale"); fakeContext.FillWith <Sale>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var fakeSale = new Sale(); fakeSale.ProductId = 1; fakeSale.Total = 1826.40M; fakeSale.Quantity = 100; fakeSale.CreatedAt = new DateTime(2020, 02, 22); fakeSale.UpdatedAt = new DateTime(2020, 08, 15); var repository = new SaleRepository(context); repository.Create(fakeSale); var createdSale = repository.GetById(6); Assert.IsType <Sale>(createdSale); Assert.Equal(6, repository.GetAll().Count()); Assert.NotEqual(0, createdSale.Id); Assert.Equal(1826.40M, createdSale.Total); Assert.Equal(100, createdSale.Quantity); Assert.Equal(new DateTime(2020, 02, 22), createdSale.CreatedAt); Assert.Equal(new DateTime(2020, 08, 15), createdSale.UpdatedAt); Assert.Equal(6, createdSale.Id); } }
public void Test_UpdateStock(int id) { var fakeContext = new FakeContext("UpdateProduct_Helper"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var productRepository = new ProductRepository(context); var repository = new SaleRepository(context); var productService = new Mock <IProductService>(); productService.Setup(x => x.GetById(It.IsAny <int>())).Returns(productRepository.GetById(id)); productService.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <Product>())) .Returns <int, Product>((productId, product) => "{ Message = Produto alterado com sucesso. }"); var update = new UpdateProduct(productService.Object); var oldSale = repository.GetById(id); var newSale = new Sale(); newSale.ProductId = id; newSale.Quantity = 15; update.UpdateStock(newSale, oldSale); Assert.Equal(115, productRepository.GetById(id).Quantity); } }
public void Test_GetAll_Products_Warehouse() { var fakeContext = new FakeContext("GetAll_Products_Warehouse"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var countProducts = context.Products.Count(); var repository = new GenericRepository <Product>(context); Assert.Equal(countProducts, repository.GetAll().Count()); Assert.IsType <GenericRepository <Product> >(repository); } }
public void Test_GetAll_Sale() { var fakeContext = new FakeContext("GetAll_Sale"); fakeContext.FillWith <Sale>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var countSales = context.Sales.Count(); var repository = new SaleRepository(context); Assert.Equal(countSales, repository.GetAll().Count()); Assert.IsType <SaleRepository>(repository); } }
public void Test_Update_Sale(int id) { var fakeContext = new FakeContext("Update_Sale"); fakeContext.FillWith <Sale>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var currentSale = repository.GetById(id); currentSale.Quantity = 200; repository.Update(id, currentSale); Assert.Equal(200, repository.GetById(id).Quantity); } }
public void Test_Delete_Product_Warehouse_Repository() { var fakeContext = new FakeContext("Delete_Products_Warehouse_Repository"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new GenericRepository <Product>(context); var currentCount = context.Products.Count(); repository.Delete(1); Assert.Equal(currentCount - 1, context.Products.Count()); } }
public void Test_Update_Product_Warehouse(int id) { var fakeContext = new FakeContext("Update_Products_Warehosue"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new GenericRepository <Product>(context); var currentProduct = repository.GetById(id); currentProduct.Name = "123abc"; repository.Update(id, currentProduct); Assert.Equal("123abc", repository.GetById(id).Name); } }
public void Test_GetAll_Products_Sale_Service() { var fakeContext = new FakeContext("GetAllProducts_Sale_Service"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var countProducts = context.Products.Count(); var repository = new ProductRepository(context); var service = new ProductService(repository); Assert.Equal(countProducts, service.GetAll().Count()); Assert.IsType <ProductRepository>(repository); Assert.IsType <ProductService>(service); } }
public void Test_Update_Product_Sale_Service(int id) { var fakeContext = new FakeContext("Update_Products_Sale_Service"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new ProductRepository(context); var service = new ProductService(repository); var currentProduct = service.GetById(id); currentProduct.Name = "123abc"; service.Update(id, currentProduct); Assert.Equal("123abc", service.GetById(id).Name); } }
public void Generic_GetById_Service(int id) { var fakeContext = new FakeContext("Generic_GetById_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new GenericRepository <Product>(context); var service = new GenericService <Product>(repository); var contextProduct = context.Products.Find(id); var serviceProduct = service.GetById(id); Assert.IsType <Product>(serviceProduct); Assert.Equal(contextProduct, serviceProduct); } }
public void Generic_Update_Product_NotFound_Service() { var fakeContext = new FakeContext("Generic_Update_Product_NotFound_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new GenericRepository <Product>(context); var service = new GenericService <Product>(repository); var contextProduct = context.Products.Find(1); contextProduct.Quantity = 150; var response = service.Update(6, contextProduct); Assert.Equal("{ Message = Produto não encontrado. }", response.ToString()); } }
public void Test_Return_Message_When_Id_NotFound() { var fakeContext = new FakeContext("Return_Message_When_Id_NotFoun_Products_Sale_Service"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new ProductRepository(context); var service = new ProductService(repository); var currentProduct = new Product("1000", "Product 1", 10M, 0, new DateTime(2019, 03, 10), new DateTime(2020, 7, 14)); var response = service.Update(6, currentProduct); Assert.Equal("{ Message = Produto não encontrado. }", response.ToString()); } }
public void Test_Return_Null_When_Id_NotFound() { var fakeContext = new FakeContext("Return_Null_When_Id_NotFound_Products_Sale_Service"); fakeContext.FillWith <Product>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new ProductRepository(context); var service = new ProductService(repository); var currentProduct = new Product("1000", "Product 1", 10M, 0, new DateTime(2019, 03, 10), new DateTime(2020, 7, 14)); Assert.Null(service.GetById(6)); Assert.Null(service.GetById(-10)); Assert.Null(service.GetById(0)); } }