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)); }
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); }
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()); }