コード例 #1
0
        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.
                }
            }
        }
コード例 #2
0
        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.");
            }
        }
コード例 #3
0
        public void InvalidStrategiesAreRejected()
        {
            var invalid = (Strategy)Int32.MinValue;

            Assert.That(() => EntryPoint.CreateStrategy(invalid), Throws.InstanceOf <ArgumentException>(), "An invalid strategy should be rejected.");
        }