public static Invoice StandardInvoice() { var invoice = new Invoice( DateTime.Now, DateTime.Now, new MonetaryValue(100000, "CO"), CustomerMother.Random()); var product = ProductMother.MartilloProductWithStock(); invoice.AddItem( name: product.Name, productId: product.Id, taxDescription: product.TaxDescription, unitPrice: product.Price, unitTax: product.Tax, quantity: new QuantityValue(2, "UM")); product = ProductMother.TaladroProductWithStock(); invoice.AddItem( name: product.Name, productId: product.Id, taxDescription: product.TaxDescription, unitPrice: product.Price, unitTax: product.Tax, quantity: new QuantityValue(1, "UM")); return(invoice); }
public void valid_insert_product() { // setp repository .Setup(rp => rp.Insert(It.IsAny <Product>())) .Verifiable(); var productRandom = ProductMother.MartilloProductWithStock(); // act var productCreate = createManager.Create( description: productRandom.Description, name: productRandom.Name, friendlyName: productRandom.FriendlyName, price: productRandom.Price, tax: productRandom.Tax, initialStock: new QuantityValue(100, "UM"), taxDescription: productRandom.TaxDescription) // val .Should() .BeOfType <ProductViewModel>(); repository.Verify(); }
public void valid_update_throw_not_found_product() { // setp var product = ProductMother.MartilloProductWithStock(); repository .Setup(rp => rp.GetById(It.IsAny <int>())) .Returns(It.IsAny <Product>()); // act - Val Assert.Throws <ProductNotFound>(() => updateManager.Update(product.Id)); }
public void valid_delete_product() { repository .Setup(rp => rp.GetById(1)) .Returns(ProductMother.MartilloProductWithStock()); // act deleteManager.Delete(1); // repository.Verify(rp => rp.Delete(It.IsAny <Product>()), Times.Once); }
public void valid_search_by_id_products() { repository .Setup(rp => rp.GetById(1)) .Returns(ProductMother.MartilloProductWithStock()) .Verifiable(); var product = searchByIdManager.Search(1); product .Should() .NotBeNull(); repository.Verify(); }
public void valid_update_name_product() { // setp var product = ProductMother.MartilloProductWithStock(); repository.Setup(rp => rp.GetById(It.IsAny <int>())) .Returns(product); var newName = "Martillo 2"; // act var productUpdate = updateManager.Update(product.Id, name: newName); productUpdate .Name .Should() .Be(newName); }
public void valid_update_description_product() { // setp var product = ProductMother.MartilloProductWithStock(); repository.Setup(rp => rp.GetById(It.IsAny <int>())) .Returns(product); var newDescription = "Nueva descripcion"; // act var productUpdate = updateManager.Update(product.Id, description: newDescription); productUpdate .Description .Should() .Be(newDescription); }
public void valid_update_price_product() { // setp var product = ProductMother.MartilloProductWithStock(); repository.Setup(rp => rp.GetById(It.IsAny <int>())) .Returns(product); var newPrice = new MonetaryValue(100, "CO"); // act var productUpdate = updateManager.Update(product.Id, price: newPrice); productUpdate .Price .Should() .Be(newPrice); }
public void valid_initial_stock_product() { // setp repository .Setup(rp => rp.Insert(It.IsAny <Product>())); var productRandom = ProductMother.MartilloProductWithStock(); var initialQuantity = new QuantityValue(100, "UM"); // act var productCreate = createManager.Create( description: productRandom.Description, name: productRandom.Name, friendlyName: productRandom.FriendlyName, price: productRandom.Price, tax: productRandom.Tax, initialStock: initialQuantity, taxDescription: productRandom.TaxDescription); // val productCreate .Should() .NotBeNull(); productCreate .StockQuantity .Should().Be(initialQuantity); productCreate .StockQuantityHistories .Should() .NotBeEmpty(); var firstHistory = productCreate.StockQuantityHistories.FirstOrDefault(); firstHistory .Should() .NotBeNull(); firstHistory .QuantityAdjustment .Should() .Be(initialQuantity); repository.Verify(); }
public void valid_update_product() { // setp var product = ProductMother.MartilloProductWithStock(); repository .Setup(rp => rp.GetById(It.IsAny <int>())) .Returns(product); repository .Setup(rp => rp.Update(It.IsAny <Product>())) .Verifiable(); // act updateManager.Update(product.Id); // val repository.Verify(); }
public void valid_update_tax_product() { // setp var product = ProductMother.MartilloProductWithStock(); repository.Setup(rp => rp.GetById(It.IsAny <int>())) .Returns(product); var newTax = new MonetaryValue(100, "CO"); var taxDescription = "IVA 20% UP"; // act var productUpdate = updateManager.Update(product.Id, tax: newTax, taxDescription: taxDescription); productUpdate .Tax .Should() .Be(newTax); productUpdate .TaxDescription .Should() .Be(taxDescription); }