public static Func <Task <bool> > WhenEvaluating(
     this IsAfterStrategyEvaluator evaluator,
     IsAfterStrategy strategy,
     IDictionary <string, string> values)
 {
     return(() => evaluator.IsOn(strategy, values));
 }
        public async Task GivenInvalidDateValue_WhenEvaluating_ThenIGetOff()
        {
            var strategy = new IsAfterStrategy {
                Settings = new DateTimeOffsetStrategySettings()
                {
                    Value = this._clock.UtcNow
                }
            };

            await this
            .GivenEvaluator()
            .WhenEvaluating(strategy, new Dictionary <string, string> {
                { StrategySettings.After, "a" }
            })
            .ThenIGet(false);
        }
        public async Task GivenMissingSettingInValues_WhenEvaluating_ThenIGetOff()
        {
            var strategy = new IsAfterStrategy {
                Settings = new DateTimeOffsetStrategySettings()
                {
                    Value = this._clock.UtcNow
                }
            };

            await this
            .GivenEvaluator()
            .WhenEvaluating(strategy, new Dictionary <string, string> {
                { "something", "0" }
            })
            .ThenIGet(false);
        }
        public async Task GivenNotAfterStrategy_WhenEvaluating_ThenIGetOff()
        {
            var strategy = new IsAfterStrategy {
                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.After, testedValue }
            })
            .ThenIGet(false);
        }
Exemple #5
0
        public async Task GivenIsAfterStrategy_WhenEvaluating_ThenIGetOn()
        {
            var serializer = this.GivenIStrategySettingsSerializer();
            var strategy   = new IsAfterStrategy()
            {
                Settings = new DateTimeOffsetStrategySettings()
                {
                    Value = this.GivenClock().UtcNow
                }
            };

            await this
            .GivenEvaluatorFactory()
            .WhenEvaluating(
                StrategyNames.IsAfter,
                serializer.Serialize(strategy.Settings),
                new Dictionary <string, string> {
                { StrategySettings.After, this.GivenClock().UtcNow.AddDays(3).ToString("O") }
            })
            .ThenIGet(true);
        }