public void GivenSoap_SellIn2_Quality2_WhenUpdated_ThenSoap_SellIn2_Quality2_Returned()
        {
            //GIVEN
            var items = new List <Item>()
            {
                new Item()
                {
                    Name = "Soap", SellIn = 2, Quality = 2
                }
            };
            var rule = new SoapUpdateRule();

            _inventoryManagementService = new InventoryManagementService(updateRule => rule);
            //WHEN
            var results = _inventoryManagementService.Update(items);
            //THEN
            var result = results.First();

            result.Should().Be("Soap 2 2");
        }
        GivenChristmasCrackers_SellIn9_Quality2_WhenUpdated_ThenChristmasCrackers_SellIn8_Quality4_Returned()
        {
            //GIVEN
            var items = new List <Item>()
            {
                new Item()
                {
                    Name = "Christmas Crackers", SellIn = 9, Quality = 2
                }
            };
            var rule = new ChristmasCrackerUpdateRule();

            _inventoryManagementService = new InventoryManagementService(updateRule => rule);
            //WHEN
            var results = _inventoryManagementService.Update(items);
            //THEN
            var result = results.First();

            result.Should().Be("Christmas Crackers 8 4");
        }
        public void GivenAgedBrie_SellIn1_Quality1_WhenUpdated_ThenAgedBrie_SellIn0_Quality2_Returned()
        {
            //GIVEN
            var items = new List <Item>()
            {
                new Item()
                {
                    Name = "Aged Brie", SellIn = 1, Quality = 1
                }
            };
            var rule = new AgedBrieUpdateRule();

            _inventoryManagementService = new InventoryManagementService(updateRule => rule);
            //WHEN
            var results = _inventoryManagementService.Update(items);
            //THEN
            var result = results.First();

            result.Should().Be("Aged Brie 0 2");
        }
        public void GivenFreshItem_SellInMinus1_Quality5_WhenUpdated_ThenFreshItem_SellInMinus2_Quality1_Returned()
        {
            //GIVEN
            var items = new List <Item>()
            {
                new Item()
                {
                    Name = "Fresh Item", SellIn = -1, Quality = 5
                }
            };
            var rule = new FreshItemUpdateRule();

            _inventoryManagementService = new InventoryManagementService(updateRule => rule);
            //WHEN
            var results = _inventoryManagementService.Update(items);
            //THEN
            var result = results.First();

            result.Should().Be("Fresh Item -2 1");
        }
Ejemplo n.º 5
0
        public IActionResult Update([FromBody] List <Item> items)
        {
            var results = _inventoryManagementService.Update(items);

            return(Ok(results));
        }