private static IValueProvider <bool> GetValueProvider(DecisionKind decisionKind) { IValueProvider <bool> valueProvider = decisionKind switch { DecisionKind.RandomStandard => _VALUEPROVIDERRANDOMSTANDARD, DecisionKind.RandomCrypto => _VALUEPROVIDERRANDOMCRYPTO, _ => throw new InvalidOperationException($"Unexpected value for {nameof(DecisionKind)} ({decisionKind}).") }; return(valueProvider); } }
// Determines that when the Decider.Decide() method is invoked // an exception is not thrown. public void WhenTheDecideMethodIsInvoked_ThenAnExceptionIsNotThrown(DecisionKind decisionKind) { Assert.DoesNotThrow(() => Decider.Decide(decisionKind)); }
/// <summary> /// Returns a random boolean value. /// </summary> /// <param name="decisionKind">Determines how the random value is generated.</param> /// <returns>A random boolean value.</returns> public static bool Decide(DecisionKind decisionKind) { IValueProvider <bool> valueProvider = GetValueProvider(decisionKind); return(valueProvider.Value); }