コード例 #1
0
        public void ComparesArgumentForEqualityToExpectedObject()
        {
            Matcher matcher = new EqualMatcher(EXPECTED);

            Assert.IsTrue(matcher.Matches(EXPECTED), "same object");
            Assert.IsTrue(matcher.Matches(EXPECTED.Clone()), "equal object");
            Assert.IsFalse(matcher.Matches("not expected"), "unequal object");
        }
コード例 #2
0
        public void ComparesArraysForEqualityByContents()
        {
            int[] expected = {1, 2};
            int[] equal = {1, 2};
            int[] inequal = {2, 3};
            int[] longer = {1, 2, 3};
            int[] shorter = {1};
            int[] empty = {};
            int[,] otherRank = {{1, 2}, {3, 4}};
            Matcher matcher = new EqualMatcher(expected);

            Assert.IsTrue(matcher.Matches(expected), "same array");
            Assert.IsTrue(matcher.Matches(equal), "same contents");
            Assert.IsFalse(matcher.Matches(inequal), "different contents");
            Assert.IsFalse(matcher.Matches(longer), "longer");
            Assert.IsFalse(matcher.Matches(shorter), "shorter");
            Assert.IsFalse(matcher.Matches(empty), "empty");
            Assert.IsFalse(matcher.Matches(otherRank), "other rank");
        }
コード例 #3
0
        public void HasAReadableDescription()
        {
            Matcher matcher = new EqualMatcher("foo");

            AssertDescription.IsEqual(new PropertyMatcher("A", matcher), "property 'A' " + matcher);
        }
コード例 #4
0
        public void HasAReadableDescription()
        {
            Matcher matcher = new EqualMatcher("foo");

            AssertDescription.IsEqual(new FieldMatcher("A", matcher), "field 'A' " + matcher);
        }
コード例 #5
0
        public void ComparesMultidimensionalArraysForEquality()
        {
            int[,] expected = {{1, 2}, {3, 4}};
            int[,] equal = {{1, 2}, {3, 4}};
            int[,] inequal = {{3, 4}, {5, 6}};
            var empty = new int[0,0];
            int[] otherRank = {1, 2};
            Matcher matcher = new EqualMatcher(expected);

            Assert.IsTrue(matcher.Matches(expected), "same array");
            Assert.IsTrue(matcher.Matches(equal), "same contents");
            Assert.IsFalse(matcher.Matches(inequal), "different contents");
            Assert.IsFalse(matcher.Matches(empty), "empty");
            Assert.IsFalse(matcher.Matches(otherRank), "other rank");
        }
コード例 #6
0
 public void CanCompareAutoboxedValues()
 {
     Matcher matcher = new EqualMatcher(1);
     Assert.IsTrue(matcher.Matches(1), "equal value");
     Assert.IsFalse(matcher.Matches(2), "other value");
 }
コード例 #7
0
        public void RecursivelyComparesContentsOfNestedLists()
        {
            var expected = new ArrayList(new[] {
                                                   new ArrayList(new[] {1, 2}),
                                                   new ArrayList(new[] {3, 4})
                                               });
            var equal = new ArrayList(new[] {
                                                new ArrayList(new[] {1, 2}),
                                                new ArrayList(new[] {3, 4})
                                            });
            var inequal = new ArrayList(new[] {
                                                  new ArrayList(new[] {2, 3}),
                                                  new ArrayList(new[] {4, 5})
                                              });
            Matcher matcher = new EqualMatcher(expected);

            Assert.IsTrue(matcher.Matches(expected), "same array");
            Assert.IsTrue(matcher.Matches(equal), "same contents");
            Assert.IsFalse(matcher.Matches(inequal), "different contents");
        }