Ejemplo n.º 1
0
        internal async Task <SaleModelUI> GetProductsAsync(string searchTerm)
        {
            var          product = new SaleModelUI();
            ProductModel result  = await GetProductByParameter(searchTerm);

            product.Crt           = productCollection.Count + 1;
            product.ProductName   = result.Name;
            product.Quantity      = quantity;
            product.Unit          = result.Unit;
            product.Subtotal      = result.RetailPrice;
            product.Tax           = Convert.ToDecimal(result.Tax) * result.RetailPrice;
            product.Total         = product.Subtotal + product.Tax;
            product.SaleUnitValue = Convert.ToDecimal(product.Quantity) * product.Total;
            Amount += product.SaleUnitValue;

            return(product);
            // re-query the database and take only the elements that match the search text
            //"SELECT * FROM Products" + (!string.IsNullOrEmpty(ProductsSearchText) ? " WHERE product_name = " + ProductsSearchText : "") + ";"
        }
Ejemplo n.º 2
0
        public async Task CanGetProductsAsync_ProductsAreTaken_ReturnsTrue()
        {
            // AAA: arrange, act, assert
            // Arrange:
            string       searchTerm = "";
            SaleModelUI  expected   = new SaleModelUI();
            ProductModel _result    = await(vm as StartupVM).GetProductByParameter(searchTerm);

            expected.Crt           = 1;// productCollection.Count + 1;
            expected.ProductName   = _result.Name;
            expected.Quantity      = 1;
            expected.Unit          = _result.Unit;
            expected.Subtotal      = _result.RetailPrice * Convert.ToDecimal(expected.Quantity);
            expected.Tax           = Convert.ToDecimal(_result.Tax) * _result.RetailPrice;
            expected.Total         = expected.Subtotal + expected.Tax;
            expected.SaleUnitValue = Convert.ToDecimal(expected.Quantity) * expected.Total;

            // Act
            var actual = await(vm as StartupVM).GetProductsAsync(searchTerm);

            // Assert

            Assert.AreEqual(expected, actual);
        }