Exemplo n.º 1
0
        public void NullTestSaveProduct()
        {
            //Arrange
            Mock <IProductRepository> mockProductRepository =
                new Mock <IProductRepository>();
            ProductDto product = null;
            IProductApplicationService productsApplicationService =
                new ProductApplicationService(mockProductRepository.Object);

            //Act & Assert
            Assert.Throws <NullReferenceException>(() => productsApplicationService
                                                   .SaveProduct(product));
        }
Exemplo n.º 2
0
        public void TestSaveProduct()
        {
            //Arrange
            Mock <IProductRepository> mockProductRepository =
                new Mock <IProductRepository>();
            ProductDto product =
                new ProductDto()
            {
                ProductName  = "Product1",
                Ingrediants  = "ingrediants",
                Descriptions = "Descriptions",
                Quantity     = 500
            };
            IProductApplicationService productsApplicationService =
                new ProductApplicationService(mockProductRepository.Object);

            //Act
            Product result = productsApplicationService.SaveProduct(product);

            //Assert
            Assert.IsType <Product>(result);
        }