Пример #1
0
        public void DoesNotMatchStaticField()
        {
            var o = new ObjectWithFields();
            Matcher m = new FieldMatcher("StaticField", new AlwaysMatcher(true, "anything"));

            Assert.IsFalse(m.Matches(o), "should not match o; field is static");
        }
Пример #2
0
        public void DoesNotMatchObjectIfItDoesNotHaveNamedField()
        {
            var o = new ObjectWithFields();
            Matcher m = new FieldMatcher("FavouriteColour", new AlwaysMatcher(true, "anything"));

            Assert.IsFalse(m.Matches(o), "should not match o; field does not exist");
        }
Пример #3
0
        public void DoesNotMatchObjectIfValueMatcherDoesNotMatch()
        {
            var o = new ObjectWithFields();
            o.PublicField = "actual value";
            Matcher m = new FieldMatcher("PublicField", new SameMatcher("some other value"));

            Assert.IsFalse(m.Matches(o), "should match o; value is different");
        }
Пример #4
0
        public void DoesNotMatchNonPublicField()
        {
            var o = new ObjectWithFields();
            Matcher m = new FieldMatcher("protectedField", new AlwaysMatcher(true, "anything"));

            Assert.IsFalse(m.Matches(o), "should not match o; field is protected");

            m = new FieldMatcher("privateField", new AlwaysMatcher(true, "anything"));

            Assert.IsFalse(m.Matches(o), "should not match o; field is private");
        }
Пример #5
0
        public void MatchesObjectWithMatchingField()
        {
            var o = new ObjectWithFields();
            o.PublicField = "actual value";
            Matcher m = new FieldMatcher("PublicField", Is.Same("actual value"));

            Assert.IsTrue(m.Matches(o), "should match o");
        }