Exemple #1
0
        public void Product_NewProduct_ShouldBeInvalid()
        {
            //Arrange
            var product = _productTestFixture.GenerateInvalidProduct();

            //Act
            var result = product.ValidateProduct();

            //Assert
            Assert.False(result.IsValid);
            Assert.True(result.Errors.Any());

            Assert.Contains(ProductValidation.NameRequired, result.Errors.Select(e => e.ErrorMessage));
        }
Exemple #2
0
        public async Task Add_AddOnlyInvalidProduct_ShouldNotAddProduct()
        {
            //Arrange
            var product        = _productTestFixture.GenerateInvalidProduct();
            var mocker         = new AutoMocker();
            var productService = mocker.CreateInstance <ServiceProduct>();

            //Act
            await productService.AddAsyncUow(product);

            //Assert
            mocker.GetMock <IRepositoryProduct>()
            .Verify(r => r.Add(It.IsAny <Product>()), Times.Never);
            mocker.GetMock <IRepositoryProductItem>()
            .Verify(s => s.Add(It.IsAny <ProductItem>()), Times.Never);
            mocker.GetMock <IUnitOfWork>()
            .Verify(r => r.CommitAsync(), Times.Never);
        }