Ejemplo n.º 1
0
        public void Failure_LookupDoesNotContainKey()
        {
            // Setup
            var factory = new QualityAlgorithmFactory(new Dictionary <QualityStrategy, Type>()
            {
                { QualityStrategy.Stable, typeof(TestAlgorithm1) },
                { QualityStrategy.LinearDecrease, typeof(TestAlgorithm2) }
            });

            // Execution and assert
            Assert.ThrowsException <ArgumentException>(() => factory.Create(QualityStrategy.RapidDecrease));
        }
Ejemplo n.º 2
0
        public void Failure_LookupContainsWrongType()
        {
            // Setup
            var factory = new QualityAlgorithmFactory(new Dictionary <QualityStrategy, Type>()
            {
                { QualityStrategy.Stable, typeof(TestAlgorithm1) },
                { QualityStrategy.LinearDecrease, typeof(List <int>) }
            });

            // Execution and assert
            var exception = Assert.ThrowsException <GildedRoseException>(() => factory.Create(QualityStrategy.LinearDecrease));

            Assert.AreEqual($"The lookup list item relating to '{QualityStrategy.LinearDecrease}' was not compatible" +
                            $"with the IQualityAlgorithm return type.", exception.Message);
        }
Ejemplo n.º 3
0
        public void Success_QualityAlgorithmCreated()
        {
            // Setup
            var factory = new QualityAlgorithmFactory(new Dictionary <QualityStrategy, Type>()
            {
                { QualityStrategy.Stable, typeof(TestAlgorithm1) },
                { QualityStrategy.LinearDecrease, typeof(TestAlgorithm2) }
            });

            // Execution
            var result = factory.Create(QualityStrategy.LinearDecrease);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(typeof(TestAlgorithm2), result.GetType());
        }