Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                var path       = args[0];
                var fileParser = new Input.FileParser();
                var items      = fileParser.ReadFile(path);

                foreach (var item in items)
                {
                    var factory        = new DayUpdaterFactory();
                    var updateStrategy = factory.GetDayUpdater(item.Name);
                    if (updateStrategy == null)
                    {
                        Console.WriteLine("NO SUCH ITEM");
                    }
                    else
                    {
                        var updatedItem = updateStrategy.Add(item);
                        Console.WriteLine($"{updatedItem.Name} {updatedItem.SellIn} {updatedItem.Quality}");
                    }
                }
            }
            else
            {
                Console.WriteLine("Please supply one argument which should be the path to the input file");
            }
        }
        public void GetDayUpdater_InvalidItem_ReturnNull()
        {
            var target = new DayUpdaterFactory();

            var result = target.GetDayUpdater("INVALID ITEM");

            Assert.Null(result);
        }
        public void GetDayUpdater_CreatesConjured()
        {
            var target = new DayUpdaterFactory();

            var result = target.GetDayUpdater("Conjured");

            Assert.IsType <ConjuredUpdater>(result);
        }
        public void GetDayUpdater_CreatesSulfuras()
        {
            var target = new DayUpdaterFactory();

            var result = target.GetDayUpdater("Sulfuras");

            Assert.IsType <SulfurasUpdater>(result);
        }
        public void GetDayUpdater_CreatesNormalItem()
        {
            var target = new DayUpdaterFactory();

            var result = target.GetDayUpdater("Normal Item");

            Assert.IsType <NormalDayUpdater>(result);
        }
        public void GetDayUpdater_CreatesBackstagePasses()
        {
            var target = new DayUpdaterFactory();

            var result = target.GetDayUpdater("Backstage passes");

            Assert.IsType <BackstagePassesDayUpdater>(result);
        }
        public void GetDayUpdater_CreatesAgedBrie()
        {
            var target = new DayUpdaterFactory();

            var result = target.GetDayUpdater("Aged Brie");

            Assert.IsType <AgedBrieDayUpdater>(result);
        }