예제 #1
0
        public void Matches_should_report_fuzzy_comparer()
        {
            var subj    = new BetweenMatcher <double>(1.0, 2.0).OrClose(0.2);
            var failure = TestMatcherLocalizer.Failure(subj, 0.0);

            Assert.ContainsKeyWithValue("Comparer", "close by 0.2", failure.UserData);
        }
예제 #2
0
        public void MatchDateTruncateToMinutesSuccesfully()
        {
            //Arrange
            var matcher = new BetweenMatcher(DataTypeEnum.DATETIME, 1482207323000, 1482207503000);

            //Act
            var date1 = "1482207383000".ToDateTime().Value;

            date1 = date1.AddSeconds(14);
            date1 = date1.AddMilliseconds(324);
            var result = matcher.Match(date1);
            var date2  = "1470916548765".ToDateTime().Value;

            date2 = date2.AddSeconds(12);
            date2 = date2.AddMilliseconds(654);
            var result1 = matcher.Match(date2);
            var date3   = "14909198765443".ToDateTime().Value;

            date3 = date3.AddSeconds(11);
            date3 = date3.AddMilliseconds(456);
            var result2 = matcher.Match(date3);

            //Assert
            Assert.IsTrue(result);
            Assert.IsFalse(result1);
            Assert.IsFalse(result2);
        }
예제 #3
0
        public void Matches_should_report_string_comparer()
        {
            var subj    = new BetweenMatcher <string>("A", "z", StringComparer.OrdinalIgnoreCase);
            var failure = TestMatcherLocalizer.Failure(subj, "A");

            Assert.ContainsKeyWithValue("Comparer", "ordinal (ignore case)", failure.UserData);
        }
예제 #4
0
        public void Exclusive_Matches_should_detect_nominal()
        {
            var subj = new BetweenMatcher <string>("a", "z");

            Assert.True(subj.Exclusive.Matches("b"));
            Assert.False(subj.Exclusive.Matches("a"));
        }
예제 #5
0
        public void MatchDateShouldReturnFalseOnInvalidDate()
        {
            //Arrange
            var matcher = new BetweenMatcher(DataTypeEnum.DATETIME, 1470960000000, 1480960000000);

            //Act
            var result = matcher.Match(new Key("1aaa0000000", "1aaa0000000"));

            //Assert
            Assert.IsFalse(result);
        }
예제 #6
0
        public void MatchNumberShouldReturnFalseOnInvalidNumber()
        {
            //Arrange
            var matcher = new BetweenMatcher(DataTypeEnum.NUMBER, 1000001, 10540001);

            //Act
            var result = matcher.Match(new Key("1aaaaa0", "1aaaaa0"));

            //Assert
            Assert.IsFalse(result);
        }
예제 #7
0
        public void MatchShouldReturnFalseOnInvalidDataTypeWithStringKey()
        {
            //Arrange
            var matcher = new BetweenMatcher(DataTypeEnum.STRING, 1470960000000, 1480960000000);

            //Act
            var result = matcher.Match("abcd");

            //Assert
            Assert.IsFalse(result);
        }
예제 #8
0
        public void MatchShouldReturnFalseOnBooleanParameter()
        {
            //Arrange
            var matcher = new BetweenMatcher(DataTypeEnum.DATETIME, 1470960000000, 1480960000000);

            //Act
            var result = matcher.Match(true);

            //Assert
            Assert.IsFalse(result);
        }
예제 #9
0
        public void MatchShouldReturnFalseIfNullOrEmptyWithStringKey()
        {
            //Arrange
            var matcher = new BetweenMatcher(DataTypeEnum.DATETIME, 1470960000000, 1480960000000);

            //Act
            var result  = matcher.Match("");
            var result2 = matcher.Match((string)null);

            //Assert
            Assert.IsFalse(result);
            Assert.IsFalse(result2);
        }
예제 #10
0
        public void MatchDateSuccesfully()
        {
            //Arrange
            var matcher = new BetweenMatcher(DataTypeEnum.DATETIME, 1470960000000, 1480960000000);

            //Act
            var result  = matcher.Match("1470970000000".ToDateTime().Value);
            var result1 = matcher.Match("1470910000000".ToDateTime().Value);
            var result2 = matcher.Match("1490910000000".ToDateTime().Value);

            //Assert
            Assert.IsTrue(result);
            Assert.IsFalse(result1);
            Assert.IsFalse(result2);
        }
예제 #11
0
        public void MatchNumberSuccesfully()
        {
            //Arrange
            var matcher = new BetweenMatcher(DataTypeEnum.NUMBER, 1000001, 10540001);

            //Act
            var result1 = matcher.Match(1700000);
            var result2 = matcher.Match(545345);
            var result3 = matcher.Match(98981700000);

            //Assert
            Assert.IsTrue(result1);
            Assert.IsFalse(result2);
            Assert.IsFalse(result3);
        }
예제 #12
0
        public void Matches_should_apply_approximation()
        {
            var subj = new BetweenMatcher <double>(5.0, 5.5).OrClose(0.03);

            Assert.True(subj.Matches(4.99));
        }
예제 #13
0
        public void Matches_should_detect_strings_string_comparison(string s)
        {
            var subj = new BetweenMatcher <string>("A", "x", StringComparer.OrdinalIgnoreCase);

            Assert.True(subj.Matches(s));
        }
예제 #14
0
        public void Matches_should_detect_strings_nominal()
        {
            var subj = new BetweenMatcher <string>("a", "z");

            Assert.True(subj.Matches("a"));
        }