示例#1
0
        public async Task ShouldSaveDiscountObject()
        {
            //Arrange

            PoS.Sell.Domain.Discount.Discount saveDiscount = null;


            _discountRepositoryMock.Setup(x => x.Add(It.IsAny <Discount.Discount>())).Callback <Discount.Discount>(discount =>
            {
                saveDiscount = discount;
            });



            _productRepositoryMock.Setup(x => x.GetById(discountRequest.ProductDescription)).ReturnsAsync(_availableproduct.FirstOrDefault());



            //Act
            var result = await discount.CreateDiscountAsync(discountRequest);

            _discountRepositoryMock.Verify(x => x.Add(It.IsAny <Discount.Discount>()), Times.Once);

            //Assert
            Assert.NotNull(saveDiscount);
            Assert.NotNull(saveDiscount.Id);
            Assert.Equal(discountRequest.Descripcion, saveDiscount.Descripcion);
            Assert.Equal(discountRequest.Porcentaje, saveDiscount.Porcentaje);
            Assert.Equal(discountRequest.Vigencia, saveDiscount.Vigencia);
        }
示例#2
0
 public DiscountTest()
 {
     //Arrange
     _discountRepositoryMock = new Mock <IDiscountRepository>();
     _productRepositoryMock  = new Mock <IProductRepository>();
     discount          = new PoS.Sell.Domain.Discount.Discount(_discountRepositoryMock.Object, _productRepositoryMock.Object);
     _availableproduct = new List <Product>();
     _availableproduct = new List <Product> {
         new Product()
         {
             Description = "Chicles Trident 18's",
             SKU         = "7506105606053",
             Price       = new Amount()
             {
                 CurrencyId  = Guid.Parse("50bca81b-4099-4087-8469-874fdc6906cf"),
                 TotalAmount = 14
             },
             Taxes = new List <Tax>
             {
                 new Tax()
                 {
                     Id          = "b0d92892-eb04-4a34-a655-63264cc923eb",
                     Percentage  = 16,
                     Description = "IVA"
                 }
             }
         }
     };
     discountRequest = new DiscountRequest
     {
         ProductDescription = "Chicles Trident 18's",
         Descripcion        = "Descuento de chicles Trident",
         Vigencia           = new DateTime(2020, 07, 31),
         Porcentaje         = 10
     };
 }