Example #1
0
        public void DoesNotMatchStaticField()
        {
            ObjectWithFields o = new ObjectWithFields();
            Matcher          m = new FieldMatcher("StaticField", new AlwaysMatcher(true, "anything"));

            Assert.IsFalse(m.Matches(o), "should not match o; field is static");
        }
Example #2
0
        public void DoesNotMatchObjectIfItDoesNotHaveNamedField()
        {
            ObjectWithFields 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");
        }
Example #3
0
        public void MatchesObjectWithMatchingField()
        {
            ObjectWithFields o = new ObjectWithFields();

            o.PublicField = "actual value";
            Matcher m = new FieldMatcher("PublicField", Is.EqualTo("actual value"));

            Assert.IsTrue(m.Matches(o), "should match o");
        }
Example #4
0
        public void DoesNotMatchObjectIfValueMatcherDoesNotMatch()
        {
            ObjectWithFields o = new ObjectWithFields();

            o.PublicField = "actual value";
            Matcher m = new FieldMatcher("PublicField", new EqualMatcher("some other value"));

            Assert.IsFalse(m.Matches(o), "should match o; value is different");
        }
Example #5
0
        private static void FieldMatchTest(string propertyName, string fieldName)
        {
            var entityType   = new EntityType(typeof(TheDarkSideOfTheMoon));
            var property     = entityType.GetOrAddProperty(propertyName, typeof(int));
            var propertyInfo = entityType.Type.GetAnyProperty(propertyName);
            var fields       = propertyInfo.DeclaringType.GetRuntimeFields().ToDictionary(f => f.Name);

            var matchedField = new FieldMatcher().TryMatchFieldName(property, propertyInfo, fields);

            Assert.Equal(fieldName, matchedField.Name);
        }
        private static void FieldMatchTest(string propertyName, string fieldName)
        {
            var entityType = new Model().AddEntityType(typeof(TheDarkSideOfTheMoon));
            var property = entityType.GetOrAddProperty(propertyName, typeof(int));
            var propertyInfo = entityType.ClrType.GetAnyProperty(propertyName);
            var fields = propertyInfo.DeclaringType.GetRuntimeFields().ToDictionary(f => f.Name);

            var matchedField = new FieldMatcher().TryMatchFieldName(property, propertyInfo, fields);

            Assert.Equal(fieldName, matchedField.Name);
        }
Example #7
0
        public void DoesNotMatchNonPublicField()
        {
            ObjectWithFields 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");
        }
 /// <summary>
 /// Sets the request body and the matching Content-Type header using <see cref="IHttpBodyConverter"/>.
 /// </summary>
 /// <param name="httpBodyConverter">Custom http body converter.</param>
 /// <returns>Returns this <see cref="RequestMatcherBuilder"/> for futher customizations.</returns>
 public RequestMatcherBuilder Body(IHttpBodyConverter httpBodyConverter)
 {
     _body = new FieldMatcher(httpBodyConverter.Body);
     Header(CONTENT_TYPE, httpBodyConverter.ContentType);
     return(this);
 }
 /// <summary>
 /// Sets the request body
 /// </summary>
 /// <param name="body">The request body to match on.</param>
 /// <returns>Returns this <see cref="RequestMatcherBuilder"/> for further customizations.</returns>
 public RequestMatcherBuilder Body(string body)
 {
     _body = new FieldMatcher(body);
     return(this);
 }
 /// <summary>
 /// Sets the request body
 /// </summary>
 /// <param name="bodyMatcher">The matcher that is used to match the body</param>
 /// <returns>Returns this <see cref="RequestMatcherBuilder"/> for further customizations.</returns>
 public RequestMatcherBuilder Body(FieldMatcher bodyMatcher)
 {
     _body = bodyMatcher;
     return(this);
 }