public void ImplementedStrategiesArePopulated() { foreach (var strategyName in Enum.GetNames(typeof(Strategy))) { try { var expectedStrategy = Enum.Parse <Strategy>(strategyName); var implementedStrategy = EntryPoint.CreateStrategy(expectedStrategy); Assert.That(implementedStrategy, Is.Not.EqualTo(default(IStrategy)), $"The strategy `{ strategyName }` was not populated."); Assert.That(implementedStrategy.Strategy, Is.EqualTo(expectedStrategy), $"The strategy implementation for `{ strategyName }` does not support the correct strategy."); } catch (NotImplementedException) { // Take no action; this strategy was not implemented. } } }
public void StrategiesAreRecognized() { foreach (var strategy in Enum.GetNames(typeof(Strategy))) { Exception?capturedException; try { EntryPoint.CreateStrategy(Enum.Parse <Strategy>(strategy)); capturedException = null; } catch (Exception ex) { capturedException = ex; } Assert.That(capturedException, Is.Null.Or.TypeOf <NotImplementedException>(), $"The strategy `{ strategy }` was not recognized."); } }
public void InvalidStrategiesAreRejected() { var invalid = (Strategy)Int32.MinValue; Assert.That(() => EntryPoint.CreateStrategy(invalid), Throws.InstanceOf <ArgumentException>(), "An invalid strategy should be rejected."); }