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); } }
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); } }
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(); } }
public MainController(IEnumerable <Item> items, ItemCategoryClassifier itemCategoryClassifier) { _items = items; _itemCategoryClassifier = itemCategoryClassifier; }