Ejemplo n.º 1
0
 public static Func <Task <bool> > WhenEvaluating(
     this IsBeforeStrategyEvaluator evaluator,
     IsBeforeStrategy strategy,
     IDictionary <string, string> values)
 {
     return(() => evaluator.IsOn(strategy, values));
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }