Ejemplo n.º 1
0
        public void GetItem_throwsRuntimeExceptionIfRequestedItemDoesntExist()
        {
            var app = new Console.GildedRose(new Item[0]);
            var ex  = Assert.Throws <InvalidOperationException>(() => app.GetItem("foobar"));

            Assert.Equal("La secuencia no contiene ningún elemento coincidente", ex.Message);
        }
Ejemplo n.º 2
0
        public void RunWithoutError_GivenEmptyCollection()
        {
            var items = new List <Item>();
            var gR    = new Console.GildedRose(items);

            gR.UpdateQuality();
        }
Ejemplo n.º 3
0
        public void TheQualityOfAnItemIsNeverMoreThan50()
        {
            var items = new[]
            {
                new Item()
                {
                    Name = "Aged Brie", SellIn = -1, Quality = 50
                },
                new Item()
                {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 3, Quality = 49
                },
            };

            var app = new Console.GildedRose(items);

            app.UpdateQuality();

            var item  = app.GetItem("Aged Brie");
            var item2 = app.GetItem("Backstage passes to a TAFKAL80ETC concert");

            Assert.Equal("Aged Brie", item.Name);
            Assert.Equal(50, item.Quality);
            Assert.Equal(-2, item.SellIn);

            Assert.Equal("Backstage passes to a TAFKAL80ETC concert", item2.Name);
            Assert.Equal(50, item2.Quality);
            Assert.Equal(2, item2.SellIn);
        }
Ejemplo n.º 4
0
        public void ConjuredItemsDegradeInQualityTwiceAsFastAsNormalItems()
        {
            var items = new[] { new Item()
                                {
                                    Name = "Conjured Mana Cake", SellIn = 2, Quality = 30
                                } };
            var app = new Console.GildedRose(items);

            app.UpdateQuality();
            var item = app.GetItem("Conjured Mana Cake");

            Assert.Equal("Conjured Mana Cake", item.Name);
            Assert.Equal(28, item.Quality);
            Assert.Equal(1, item.SellIn);
        }
Ejemplo n.º 5
0
        public void OnceTheSellByDateHasPassed_QualityDegradesTwiceAsFast()
        {
            var items = new[] { new Item()
                                {
                                    Name = "bar", SellIn = -1, Quality = 2
                                } };
            var app = new Console.GildedRose(items);

            app.UpdateQuality();
            var item = app.GetItem("bar");

            Assert.Equal("bar", item.Name);
            Assert.Equal(0, item.Quality);
            Assert.Equal(-2, item.SellIn);
        }
Ejemplo n.º 6
0
        public void UpdateQuality_DecrementsItemsQualityAndSellInBy1()
        {
            var items = new[] { new Item()
                                {
                                    Name = "foo", Quality = 1, SellIn = 1
                                } };
            var app = new Console.GildedRose(items);

            app.UpdateQuality();
            var item = app.GetItem("foo");

            Assert.Equal("foo", item.Name);
            Assert.Equal(0, item.Quality);
            Assert.Equal(0, item.SellIn);
        }
Ejemplo n.º 7
0
        public void SulfurasBeingALegendaryItemNeverHasToBeSoldOrDecreasesInQuality()
        {
            var items = new[] { new Item()
                                {
                                    Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80
                                } };

            var app = new Console.GildedRose(items);

            app.UpdateQuality();

            var item = app.GetItem("Sulfuras, Hand of Ragnaros");

            Assert.Equal("Sulfuras, Hand of Ragnaros", item.Name);
            Assert.Equal(80, item.Quality);
            Assert.Equal(-1, item.SellIn);
        }
Ejemplo n.º 8
0
        public void BackstagePassesIncreaseInQualityBy3WhenThereAre5DaysOrLessRemaining()
        {
            var items = new[] { new Item()
                                {
                                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = 33
                                } };

            var app = new Console.GildedRose(items);

            app.UpdateQuality();

            var item = app.GetItem("Backstage passes to a TAFKAL80ETC concert");

            Assert.Equal("Backstage passes to a TAFKAL80ETC concert", item.Name);
            Assert.Equal(36, item.Quality);
            Assert.Equal(4, item.SellIn);
        }
Ejemplo n.º 9
0
        public void BackstagePassesQualityDropsTo0AfterTheConcert()
        {
            var items = new[] { new Item()
                                {
                                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = -1, Quality = 30
                                } };

            var app = new Console.GildedRose(items);

            app.UpdateQuality();

            var item = app.GetItem("Backstage passes to a TAFKAL80ETC concert");

            Assert.Equal("Backstage passes to a TAFKAL80ETC concert", item.Name);
            Assert.Equal(0, item.Quality);
            Assert.Equal(-2, item.SellIn);
        }
Ejemplo n.º 10
0
        public void BackstagePassesQualityIncrementsByOneWithEachDayPassing()
        {
            var items = new[] { new Item()
                                {
                                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 11, Quality = 30
                                } };

            var app = new Console.GildedRose(items);

            app.UpdateQuality();

            var item = app.GetItem("Backstage passes to a TAFKAL80ETC concert");

            Assert.Equal("Backstage passes to a TAFKAL80ETC concert", item.Name);
            Assert.Equal(31, item.Quality);
            Assert.Equal(10, item.SellIn);
        }
Ejemplo n.º 11
0
        public void BriesQualityIncrementsByOneForEachDayPastItsSellByDate()
        {
            var items = new[] { new Item()
                                {
                                    Name = "Aged Brie", SellIn = -1, Quality = 1
                                } };

            var app = new Console.GildedRose(items);

            app.UpdateQuality();

            var item = app.GetItem("Aged Brie");

            Assert.Equal("Aged Brie", item.Name);
            Assert.Equal(3, item.Quality);
            Assert.Equal(-2, item.SellIn);
        }
Ejemplo n.º 12
0
        public void QualityOfItemIncreasesBy3AtEndOfDay_GivenItemIsBackstagePassesAndSellinIsLessThan5Days()
        {
            // Arrage
            var items = new List <Item> {
                new Item()
                {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = 5, Quality = 1
                }
            };

            // Act
            var gr = new Console.GildedRose(items);

            gr.UpdateQuality();

            // Assert
            Assert.Equal(4, items[0].Quality);
        }
Ejemplo n.º 13
0
        public void QualityOfItemDropsToZeroAtEndOfDay_GivenItemIsBackstagePassesAndConcertIsOver()
        {
            // Arrage
            var items = new List <Item> {
                new Item()
                {
                    Name = "Backstage passes to a TAFKAL80ETC concert", SellIn = -1, Quality = 10
                }
            };

            // Act
            var gr = new Console.GildedRose(items);

            gr.UpdateQuality();

            // Assert
            Assert.Equal(0, items[0].Quality);
        }
Ejemplo n.º 14
0
        public void LowerQualityValueAtEndOfDay_GivenNormalItem()
        {
            // Arrage
            var items = new List <Item> {
                new Item()
                {
                    Name = "Normal Item", SellIn = 5, Quality = 30
                }
            };

            // Act
            var gr = new Console.GildedRose(items);

            gr.UpdateQuality();

            // Assert
            Assert.Equal(29, items[0].Quality);
        }
Ejemplo n.º 15
0
        public void QualityOfItemNeverIncreaseMoreThan50AtEndOfDay_GivenItemIsAgedBrie()
        {
            // Arrage
            var items = new List <Item> {
                new Item()
                {
                    Name = "Aged Brie", SellIn = 5, Quality = 50
                }
            };

            // Act
            var gr = new Console.GildedRose(items);

            gr.UpdateQuality();

            // Assert
            Assert.Equal(50, items[0].Quality);
        }
Ejemplo n.º 16
0
        public void QualityOfItemCanNotBeNegativeAtEndOfDay_GivenNormalItemAndSellByDatePassed()
        {
            // Arrage
            var items = new List <Item> {
                new Item()
                {
                    Name = "Normal Item", SellIn = 0, Quality = 1
                }
            };

            // Act
            var gr = new Console.GildedRose(items);

            gr.UpdateQuality();

            // Assert
            Assert.Equal(-1, items[0].SellIn);
            Assert.Equal(0, items[0].Quality);
        }
Ejemplo n.º 17
0
        public void QualityOfAnItemIsNeverNegative()
        {
            var items = new[] { new Item()
                                {
                                    Name = "foo", SellIn = 2, Quality = 2
                                } };

            var app = new Console.GildedRose(items);

            app.UpdateQuality();
            app.UpdateQuality();
            app.UpdateQuality();

            var item = app.GetItem("foo");

            Assert.Equal("foo", item.Name);
            Assert.Equal(0, item.Quality);
            Assert.Equal(-1, item.SellIn);
        }
Ejemplo n.º 18
0
        public void QualityNeverChangesAtEndOfDay_GivenItemIsSulfuras()
        {
            // Arrage
            var items = new List <Item> {
                new Item()
                {
                    Name = "Sulfuras, Hand of Ragnaros", SellIn = 5, Quality = 50
                }
            };

            // Act
            var gr = new Console.GildedRose(items);

            gr.UpdateQuality();

            // Assert
            Assert.Equal(50, items[0].Quality);
            Assert.Equal(5, items[0].SellIn);
        }
Ejemplo n.º 19
0
        public void LowerQualityByTwiceValueAtEndOfDay_GivenNormalItemAndSellByDatePassed()
        {
            // Arrage
            var items = new List <Item> {
                new Item()
                {
                    Name = "Normal Item", SellIn = 0, Quality = 30
                }
            };

            // Act
            var gr = new Console.GildedRose(items);

            gr.UpdateQuality();

            // Assert
            Assert.Equal(-1, items[0].SellIn);
            Assert.Equal(28, items[0].Quality);
        }