コード例 #1
0
 static StrategySelector()
 {
     backstagePassStrategy = new BackstagePassStrategy();
     agedBrieStrategy      = new AgedBrieStrategy();
     regularItemStrategy   = new RegularItemStrategy();
     sulfurasStrategy      = new SulfurasStrategy();
     conjuredStrategy      = new ConjuredStrategy();
 }
コード例 #2
0
        public void DecreaseSellIn_DecreasesSellInByOne()
        {
            var item = new Item {
                SellIn = 1
            };
            var subject = new BackstagePassStrategy(item);

            subject.DecreaseSellIn();

            Assert.That(item.SellIn, Is.EqualTo(0));
        }
コード例 #3
0
        public void PerformPreSellByUpdate_IncreasesQualityByThree_WhenSellInIsBetweenFiveAndOne(int sellIn)
        {
            var item = new Item {
                Quality = 1, SellIn = sellIn
            };
            var subject = new BackstagePassStrategy(item);

            subject.PerformPreSellByUpdate();

            Assert.That(item.Quality, Is.EqualTo(4));
        }
コード例 #4
0
        public void PerformPreSellByUpdate_IncreasesQualityByOne_WhenSellInIsGreaterThanTen(int sellIn)
        {
            var item = new Item {
                Quality = 1, SellIn = sellIn
            };
            var subject = new BackstagePassStrategy(item);

            subject.PerformPreSellByUpdate();

            Assert.That(item.Quality, Is.EqualTo(2));
        }
コード例 #5
0
        public void PerformPostSellByUpdate_SetsQualityToZero()
        {
            var item = new Item {
                Quality = 10
            };
            var subject = new BackstagePassStrategy(item);

            subject.PerformPostSellByUpdate();

            Assert.That(item.Quality, Is.EqualTo(0));
        }
コード例 #6
0
        public void ItemQualityManager_UpdateBackStagePass_QualityChanges(int currentSellIn, int expectedQuality)
        {
            // Arrange
            var strategy = new BackstagePassStrategy();
            var item     = new ItemBuilder(Constants.BackstagePass)
                           .WithQuality(20)
                           .WithSellIn(currentSellIn)
                           .Build();

            // Act
            strategy.UpdateItemQuality(item);

            // Assert
            Assert.Equal(expectedQuality, item.Quality);
        }
コード例 #7
0
        public void UpdateQuality_WhenSellInDaysIsHigherThanZero_DecreasesSellInByOne()
        {
            // Arrange
            var item = new Item {
                SellIn = 5
            };
            var backstagePassStrategy = new BackstagePassStrategy();

            // Act
            backstagePassStrategy.UpdateQuality(item);

            // Assert
            var expectedSellInDays = 4;

            Assert.Equal(expectedSellInDays, item.SellIn);
        }
コード例 #8
0
        public void UpdateQuality_WhenSellInDaysIsBelowZero_DecreasesQualityToZero()
        {
            // Arrange
            var item = new Item {
                SellIn = -1, Quality = 5
            };
            var backstagePassStrategy = new BackstagePassStrategy();

            // Act
            backstagePassStrategy.UpdateQuality(item);

            // Assert
            var expectedQuality = 0;

            Assert.Equal(expectedQuality, item.Quality);
        }
コード例 #9
0
        public void UpdateQuality_WhenSellInDaysIs_IncreasesQualityBy(int initialSellIn, int qualityShouldIncreaseBy)
        {
            // Arrange
            const int initialQuality = 5;
            var       item           = new Item {
                SellIn = initialSellIn, Quality = initialQuality
            };
            var backstagePassStrategy = new BackstagePassStrategy();

            // Act
            backstagePassStrategy.UpdateQuality(item);

            // Assert
            var expectedQuality = initialQuality + qualityShouldIncreaseBy;

            Assert.Equal(expectedQuality, item.Quality);
        }