Esempio n. 1
0
        public void MakesSureNameIsNotChangedAfterUpdatingStateTest()
        {
            var items = new List <Item>
            {
                new() { Name = "foo", SellIn = 0, Quality = 0 }
            };
            var categoryClassifier = new ItemCategoryClassifier();
            var app = new MainController(items, categoryClassifier);

            app.UpdateDailyItemState();
            Assert.Equal("foo", items[0].Name);
        }
    }
Esempio n. 2
0
        public static void UpdateDailyItemState(this Item item, ItemCategoryClassifier itemCategoryClassifier)
        {
            var category          = itemCategoryClassifier.GetItemCategory(item.Name);
            var changeStateGetter = NamedChanges.Get(category);

            changeStateGetter.ApplyEarlyChanges(item);

            if (category != ItemCategoryEnum.Sulfuras)
            {
                item.SellIn--;
            }

            if (item.SellIn < 0)
            {
                changeStateGetter.ApplyLateChanges(item);
            }
        }
Esempio n. 3
0
        public static async Task RunAll()
        {
            Console.WriteLine("OMGHAI!");

            var appConfiguration = await BuildItemsDataSet();

            var categoryClassifier = new ItemCategoryClassifier();

            var app = new MainController(appConfiguration.Items, categoryClassifier);

            for (var i = 0; i < appConfiguration.DaysToUpdate; i++)
            {
                Console.WriteLine($"-------- day {i} --------");
                DisplayItemsStatus(appConfiguration.Items);
                app.UpdateDailyItemState();
            }
        }
Esempio n. 4
0
 public MainController(IEnumerable <Item> items, ItemCategoryClassifier itemCategoryClassifier)
 {
     _items = items;
     _itemCategoryClassifier = itemCategoryClassifier;
 }