コード例 #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"));
        }