public static Func <Task <bool> > WhenEvaluating( this IsBeforeStrategyEvaluator evaluator, IsBeforeStrategy strategy, IDictionary <string, string> values) { return(() => evaluator.IsOn(strategy, values)); }
public async Task GivenInvalidDateValue_WhenEvaluating_ThenIGetOff() { var strategy = new IsBeforeStrategy { Settings = new DateTimeOffsetStrategySettings() { Value = this._clock.UtcNow } }; await this .GivenEvaluator() .WhenEvaluating(strategy, new Dictionary <string, string> { { StrategySettings.Before, "a" } }) .ThenIGet(false); }
public async Task GivenMissingSettingInValues_WhenEvaluating_ThenIGetOff() { var strategy = new IsBeforeStrategy { Settings = new DateTimeOffsetStrategySettings() { Value = this._clock.UtcNow } }; await this .GivenEvaluator() .WhenEvaluating(strategy, new Dictionary <string, string> { { "something", "0" } }) .ThenIGet(false); }
public async Task GivenNotBeforeStrategy_WhenEvaluating_ThenIGetOff() { var strategy = new IsBeforeStrategy { Settings = new DateTimeOffsetStrategySettings { Value = this._clock.UtcNow } }; var testedValue = this._clock.UtcNow.AddDays(2).ToString("O"); await this .GivenEvaluator() .WhenEvaluating(strategy, new Dictionary <string, string> { { StrategySettings.Before, testedValue } }) .ThenIGet(false); }
public async Task GivenIBeforeStrategy_WhenEvaluating_ThenIGetOn() { var serializer = this.GivenIStrategySettingsSerializer(); var strategy = new IsBeforeStrategy() { Settings = new DateTimeOffsetStrategySettings() { Value = this.GivenClock().UtcNow } }; await this .GivenEvaluatorFactory() .WhenEvaluating( StrategyNames.IsBefore, serializer.Serialize(strategy.Settings), new Dictionary <string, string> { { StrategySettings.Before, this.GivenClock().UtcNow.AddDays(-3).ToString("O") } }) .ThenIGet(true); }