Ejemplo n.º 1
0
        public void ProductStock_FindByPriceRangeReturnsCorrectEmptyCollection(decimal lo, decimal hi)
        {
            var stock = new ProductStock();

            stock.Add(new Product("SSD", 12.4m, 3));
            stock.Add(new Product("CPU", 16.5m, 3));
            stock.Add(new Product("HDD", 20.7m, 3));
            stock.Add(new Product("RAM", 14.9m, 3));

            var result = stock.FindAllInRange(lo, hi);

            Assert.AreEqual(result.Count(), 0);
        }
Ejemplo n.º 2
0
        public void ProductStock_FindByPriceRangeReturnsCorrectNonEmptyCollection(decimal lo, decimal hi, string orderNames)
        {
            var stock = new ProductStock();

            stock.Add(new Product("SSD", 12.4m, 3));
            stock.Add(new Product("CPU", 16.5m, 3));
            stock.Add(new Product("HDD", 20.7m, 3));
            stock.Add(new Product("RAM", 14.9m, 3));
            var result = stock.FindAllInRange(lo, hi);
            var names  = orderNames.Split(" ").ToArray();
            int i      = 0;

            foreach (var item in result)
            {
                Assert.AreEqual(item.CompareTo(new Product(names[i++], 12.4m, 3)), 0);
            }
        }
Ejemplo n.º 3
0
        public void FindAllInPriceRange_ReturnsProductsOrEmptyCollection(decimal min, decimal max)
        {
            var productsInRange = new List <IProduct>();

            for (int i = 0; i < 2; i++)
            {
                var product = new Product($"{i}", 1.1m, 1);
                productStock.Add(product);

                if (product.Price >= min && product.Price <= max)
                {
                    productsInRange.Add(product);
                }
            }

            var productsFound = productStock.FindAllInRange(min, max);

            CollectionAssert.AreEqual(productsFound, productsInRange);
        }
Ejemplo n.º 4
0
        public void FindAllInRange_ShouldReturnEmptyEnumeration()
        {
            var actual = productStock.FindAllInRange(10, 22);

            Assert.IsEmpty(actual);
        }