Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            System.Console.WriteLine("OMGHAI!");

            var app = new Program
                {
                    Items = new List<Item>
                        {
                            new RegularItem {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
                            new AgedBrieItem {Name = "Aged Brie", SellIn = 2, Quality = 0},
                            new RegularItem {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
                            new SulfurasItem {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80},
                            new BackstagePassItem
                                {
                                    Name = "Backstage passes to a TAFKAL80ETC concert",
                                    SellIn = 15,
                                    Quality = 20
                                },
                            new ConjuredItem {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
                        }
                };

            app.UpdateQuality();

            System.Console.ReadKey();
        }
Ejemplo n.º 2
0
 public void Given_brie_When_processed_the_amount_should_reduce_by_one()
 {
     Program sut = new Program { Items = new List<Item> { new Item { Name = "Aged Brie", SellIn = 0, Quality = 50 } } };
     sut.UpdateQuality();
     sut.Items[0].Name.ShouldBe("Aged Brie");
     sut.Items[0].Quality.ShouldBe(50);
 }
Ejemplo n.º 3
0
        public static Item UpdateQuality(this Item item)
        {
            var program = new Program {Items = new List<Item> {item}};
            program.UpdateQuality();

            return item;
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("OMGHAI!");

            var app = new Program()
                          {
                              items = new List<Item>
                                          {
                                              new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
                                              new Item {Name = "Aged Brie", SellIn = 2, Quality = 0},
                                              new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
                                              new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80},
                                              new Item
                                                  {
                                                      Name = "  ",
                                                      SellIn = 15,
                                                      Quality = 20
                                                  },
                                              new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
                                          }
                          };

            app.UpdateQuality();

            System.Console.ReadKey();
        }
Ejemplo n.º 5
0
        public void AgedQulityTest()
        {
            Program app = new Program();

            app.Items = new List<Item> { new Item { Name = "Aged Brie", SellIn = 0, Quality = 0 } };
            app.UpdateQuality();
            Assert.Equal(2, app.Items[0].Quality);
        }
 public void Given_mongoose_elixir_When_processed_the_amount_should_reduce_by_one()
 {
     Program sut = new Program { Items = new List<Item> { new Item { Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7 } } };
     sut.UpdateQuality();
     sut.Items[0].Name.ShouldBe("Elixir of the Mongoose");
     sut.Items[0].SellIn.ShouldBe(4);
     sut.Items[0].Quality.ShouldBe(6);
 }
 public void Given_ragnoros_hand_When_processed_the_amount_should_reduce_by_one()
 {
     Program sut = new Program { Items = new List<Item> { new Item { Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 50 } } };
     sut.UpdateQuality();
     sut.Items[0].Name.ShouldBe("Sulfuras, Hand of Ragnaros");
     sut.Items[0].SellIn.ShouldBe(0);
     sut.Items[0].Quality.ShouldBe(50);
 }
 public void Given_backstage_passes_When_processed_the_amount_should_reduce_by_one()
 {
     Program sut = new Program { Items = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 15, Quality = 20 } } };
     sut.UpdateQuality();
     sut.Items[0].Name.ShouldBe("Backstage passes to a TAFKAL80ETC concert");
     sut.Items[0].SellIn.ShouldBe(14);
     sut.Items[0].Quality.ShouldBe(21);
 }
 public void Given_mana_cake_When_processed_the_amount_should_reduce_by_one()
 {
     Program sut = new Program { Items = new List<Item> { new Item { Name = "Conjured Mana Cake", SellIn = 3, Quality = 6 } } };
     sut.UpdateQuality();
     sut.Items[0].Name.ShouldBe("Conjured Mana Cake");
     sut.Items[0].SellIn.ShouldBe(2);
     sut.Items[0].Quality.ShouldBe(5);
 }
Ejemplo n.º 10
0
 public void Given_backstage_passes_When_processed_after_sell_in_date_the_quality_should_be_zero()
 {
     Program sut = new Program { Items = new List<Item> { new Item { Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = -1, Quality = 20 } } };
     sut.UpdateQuality();
     sut.Items[0].Name.ShouldBe("Backstage passes to a TAFKAL80ETC concert");
     sut.Items[0].SellIn.ShouldBe(-2);
     sut.Items[0].Quality.ShouldBe(0);
 }
Ejemplo n.º 11
0
 public void Given_mongoose_elixir_When_sell_in_date_is_0_should_reduce_by_on()
 {
     Program sut = new Program { Items = new List<Item> { new Item { Name = "Elixir of the Mongoose", SellIn = -1, Quality = 7 } } };
     sut.UpdateQuality();
     sut.Items[0].Name.ShouldBe("Elixir of the Mongoose");
     sut.Items[0].SellIn.ShouldBe(-2);
     sut.Items[0].Quality.ShouldBe(5);
 }
Ejemplo n.º 12
0
 public void Given_a_vest_When_processed_the_amount_should_reduce_by_one()
 {
     Program sut = new Program { Items = new List<Item> { new Item { Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20 } } };
     sut.UpdateQuality();
     sut.Items[0].Name.ShouldBe("+5 Dexterity Vest");
     sut.Items[0].SellIn.ShouldBe(9);
     sut.Items[0].Quality.ShouldBe(19);
 }
Ejemplo n.º 13
0
        public void ConjuredQulityDecreaseTest()
        {
            Program app = new Program();

            app.Items = new List<Item> { new Item { Name = "Conjured Mana Cake", SellIn = 3, Quality = 6 } };
            app.UpdateQuality();
            Assert.Equal(4, app.Items[0].Quality);
            Assert.Equal(2, app.Items[0].SellIn);
        }
Ejemplo n.º 14
0
        public void AgingMaxQulityTest()
        {
            Program app = new Program();

            app.Items = new List<Item> { new Item { Name = "Aged Brie", SellIn = 1, Quality = 50 } };
            app.UpdateQuality();
            Assert.Equal(50, app.Items[0].Quality);
            Assert.Equal(0, app.Items[0].SellIn);
        }
Ejemplo n.º 15
0
        public void ConjuredExpiredQulityZeroTest()
        {
            Program app = new Program();

            app.Items = new List<Item> { new Item { Name = "Conjured Mana Cake", SellIn = 0, Quality = 0 } };
            app.UpdateQuality();
            Assert.Equal(0, app.Items[0].Quality);
            Assert.Equal(-1, app.Items[0].SellIn);
        }
Ejemplo n.º 16
0
        private void ItemShouldDecreaseOneQuality(int quality, int sellIn)
        {
            var app = new GildedRose.Console.Program();
            app.Items = new List<Item> { new Item { Name = ItemToTest, SellIn = sellIn, Quality = quality } };

            app.UpdateQuality();
            var resultSellInValue = app.Items.First().Quality;

            Assert.AreEqual(resultSellInValue, quality - 1);
        }
Ejemplo n.º 17
0
        public virtual void GivenZeroQuality_WithTwentySellIn_ThenItemQualityShouldNeverBeLessThanZero()
        {
            var app = new GildedRose.Console.Program();
            app.Items = new List<Item> { new Item { Name = ItemToTest, SellIn = 20, Quality = 0 } };

            app.UpdateQuality();
            var resultQuality = app.Items.First().Quality;

            Assert.GreaterOrEqual(resultQuality, 0);
        }
Ejemplo n.º 18
0
        public virtual void GivenFiftyQuality_WithTwentySellIn_ThenItemQualityShouldBeLessThanFiftyOne()
        {
            var app = new GildedRose.Console.Program();
            app.Items = new List<Item> { new Item { Name = ItemToTest, SellIn = 20, Quality = 50 } };

            app.UpdateQuality();
            var resultQuality = app.Items.First().Quality;

            Assert.Less(resultQuality, 51);
        }
Ejemplo n.º 19
0
        private void SulfurasShouldNeverDecreaseInQuality(int quality, int sellIn)
        {
            var app = new GildedRose.Console.Program();
            app.Items = new List<Item> { new Item { Name = ItemToTest, SellIn = sellIn, Quality = quality } };

            app.UpdateQuality();
            var resultQuality = app.Items.First().Quality;

            Assert.AreEqual(resultQuality, quality);
        }
        private void BackStatePassShouldBeZeroQuality(int quality, int sellin)
        {
            var app = new GildedRose.Console.Program();
            app.Items = new List<Item> { new Item { Name = ItemToTest, SellIn = sellin, Quality = quality } };

            app.UpdateQuality();
            var resultQuality = app.Items.First().Quality;

            Assert.AreEqual(resultQuality, 0);
        }
Ejemplo n.º 21
0
        public void QuailityDegradesByTwoWhenPastTheSellinPeriod()
        {
            var item = new Item { Name = "+5 Dexterity Vest", Quality = 20, SellIn = 0 };
            var subject = new Program
            {
                Items = new List<Item> { item }
            };

            subject.UpdateQuality();
            Assert.That(item.Quality, Is.EqualTo(18));
        }
Ejemplo n.º 22
0
        public void QuailityCanNeverBeMoreThanFifty()
        {
            var item = new Item { Name = "Aged Brie", SellIn = 2, Quality = 50 };
            var subject = new Program
            {
                Items = new List<Item> { item }
            };

            subject.UpdateQuality();
            Assert.That(item.Quality, Is.EqualTo(50));
        }
Ejemplo n.º 23
0
        public void QuailityOfAnItemIsNeverNegative()
        {
            var item = new Item { Name = "+5 Dexterity Vest", Quality = 0, SellIn = 0 };
            var subject = new Program
            {
                Items = new List<Item> { item }
            };

            subject.UpdateQuality();
            Assert.That(item.Quality, Is.EqualTo(0));
        }
Ejemplo n.º 24
0
        public void ConjuredDegradesTwiceAsFast()
        {
            var item = new Item { Name = "Conjured", Quality = 20, SellIn = 10 };
            var subject = new Program
            {
                Items = new List<Item> { item }
            };

            subject.UpdateQuality();
            Assert.That(item.Quality, Is.EqualTo(18));
        }
Ejemplo n.º 25
0
 public void Update(int step)
 {
     System.Console.WriteLine("================ {0} ===================", step);
     var reference = new Program();
     var refactored = new Program();
     while(step-->0)
     {
       reference.OldUpdateQuality();
       refactored.NewUpdateQuality();
     }
     Assert.IsTrue( AreEquivalent(refactored.Items, reference.Items, TestAssemblyTests.AreEqual) );
 }
Ejemplo n.º 26
0
 public void ThirtyFiveUpdatesIsEnough()
 {
     System.Console.WriteLine("================ 35 updates is enough ===================");
     var updateA = new Program();
     var updateB = new Program();
     for(var i=1; i<=34; i++)
     {
       updateA.OldUpdateQuality();
       updateB.OldUpdateQuality();
     }
     updateB.OldUpdateQuality();
     Assert.IsTrue( AreEquivalent(updateA.Items, updateB.Items, TestAssemblyTests.QualityAreEqual) );
 }
Ejemplo n.º 27
0
        public static void Main(string[] args)
        {
            System.Console.WriteLine("OMGHAI!");

            var app = new Program()
                          {
                              Items = new List<Item>
                                          {
                                              new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
                                              new Item {Name = "Aged Brie", SellIn = 2, Quality = 0},
                                              new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
                                              new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80},
                                              new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80},
                                              new Item
                                                  {
                                                      Name = "Backstage passes to a TAFKAL80ETC concert",
                                                      SellIn = 15,
                                                      Quality = 20
                                                  },
                                              new Item
                                                  {
                                                      Name = "Backstage passes to a TAFKAL80ETC concert",
                                                      SellIn = 10,
                                                      Quality = 49
                                                  },
                                              new Item
                                                  {
                                                      Name = "Backstage passes to a TAFKAL80ETC concert",
                                                      SellIn = 5,
                                                      Quality = 49
                                                  },
                                              // this conjured item does not work properly yet
                                              new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
                                          }

                          };

            for (var i = 0; i < 31; i++)
            {
                System.Console.WriteLine("-------- day " + i + " --------");
                System.Console.WriteLine("name, sellIn, quality");
                for (var j = 0; j < app.Items.Count; j++)
                {
                    System.Console.WriteLine(app.Items[j].Name + ", " + app.Items[j].SellIn + ", " + app.Items[j].Quality);
                }
                System.Console.WriteLine("");
                app.UpdateQuality();
            }
        }
Ejemplo n.º 28
0
 private static ItemUpdater Create(Program.Item item)
 {
     switch (item.Name)
     {
         case "Aged Brie":
             return new AgedBrieUpdater(item);
         case "Backstage passes to a TAFKAL80ETC concert":
             return new BackstagePassUpdater(item);
         case "Sulfuras, Hand of Ragnaros":
             return new SulfurasItemUpdater(item);
         case "Conjured Mana Cake":
             return new ConjuredItemUpdater(item);
         default:
             return new ItemUpdater(item);
     }
 }
        public void Setup()
        {
            app = new Program()
            {
                Items = new List<Item>
                {
                    new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
                    new Item {Name = "Aged Brie", SellIn = 2, Quality = 0},
                    new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
                    new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80},
                    new Item
                        {
                            Name = "Backstage passes to a TAFKAL80ETC concert",
                            SellIn = 15,
                            Quality = 20
                        },
                    new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
                }

            };
        }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("KEKBUR 50 DKP MINUS!");

            Program app = new Program()
            {
                Items = new List<Item>
                {
                    new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
                    new Item {Name = "Aged Brie", SellIn = 2, Quality = 0},
                    new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
                    new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80},
                    new Item {Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 15, Quality = 20},
                    new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
                }
            };

            app.UpdateQuality();

            System.Console.ReadKey();
        }