示例#1
0
        public bool IsComparisonValid(IKeyValueDefinition <float> definition, float value,
                                      NumberComparison comparison)
        {
            var dbValue = _database.Get(definition.Key, definition.DefaultValue);

            switch (comparison)
            {
            case NumberComparison.Equal:
                return(Math.Abs(dbValue - value) < 0.01f);

            case NumberComparison.NotEqual:
                return(Math.Abs(dbValue - value) > 0.01f);

            case NumberComparison.GreaterThan:
                return(value > dbValue);

            case NumberComparison.GreaterThanOrEqual:
                return(value >= dbValue);

            case NumberComparison.LessThan:
                return(value < dbValue);

            case NumberComparison.LessThanOrEqual:
                return(value <= dbValue);

            default:
                throw new ArgumentOutOfRangeException(nameof(comparison), comparison, null);
            }
        }
示例#2
0
        public void BeforeEach()
        {
            _definition = Substitute.For <IKeyValueDefinition <int> >();
            _database   = Substitute.For <IKeyValueData <int> >();
            _condition  = new ConditionIntInternal(_database);

            _database.Get(null).ReturnsForAnyArgs(0);
        }
        public void BeforeEach()
        {
            _definition = Substitute.For <IKeyValueDefinition <string> >();
            _database   = Substitute.For <IKeyValueData <string> >();
            _condition  = new ConditionStringInternal(_database);

            _database.Get(null).ReturnsForAnyArgs(VALUE);
        }
        public void BeforeEach()
        {
            _definition    = Substitute.For <IKeyValueDefinition <bool> >();
            _database      = Substitute.For <IKeyValueData <bool> >();
            _boolCondition = new ConditionLocalBoolInternal(_database);

            _database.Get(null).ReturnsForAnyArgs(true);
        }
示例#5
0
        public bool AreValuesEqual(IKeyValueDefinition <string> definition, string value)
        {
            var kvp = _database.Get(definition.Key, definition.DefaultValue);

            return(kvp == value);
        }