public void ShouldReadEmptyObject() { var properties = reader.Properties(new object()); Assert.That(properties, Is.Not.Null); Assert.That(properties.Count, Is.EqualTo(0)); }
public static void HasApiRoute(HttpConfiguration config, string url, HttpMethod httpMethod, string body, object expectations) { var propertyReader = new PropertyReader(); var expectedProps = propertyReader.Properties(expectations); HasApiRoute(config, url, httpMethod, body, expectedProps); }
private void AddParameters(MethodCallExpression methodCall, IDictionary <string, string> values) { var attributeRecogniser = new AttributeRecogniser(); var propertyReader = new PropertyReader(); var parameters = methodCall.Method.GetParameters(); var arguments = methodCall.Arguments; for (int i = 0; i < parameters.Length; i++) { var param = parameters[i]; var expectedValue = GetExpectedValue(arguments[i]); var isFromBody = attributeRecogniser.IsFromBody(param); if (expectedValue != null || !isFromBody) { if (propertyReader.IsSimpleType(param.ParameterType)) { var expectedString = expectedValue != null?expectedValue.ToString() : null; values.Add(param.Name, expectedString); } else { var objectFieldValues = propertyReader.Properties(expectedValue); foreach (var field in objectFieldValues) { values.Add(field.Key.ToLowerInvariant(), field.Value); } } } } }
public static void HasRoute(RouteCollection routes, string url, string body, object expectations) { var propertyReader = new PropertyReader(); var expectedProps = propertyReader.Properties(expectations); HasRoute(routes, url, body, expectedProps); }
public static void HasApiRoute(HttpConfiguration config, string url, HttpMethod httpMethod, string body, object expectations) { var propertyReader = new PropertyReader(); var expectedProps = propertyReader.Properties(expectations); HasApiRoute(config, url, httpMethod, body, expectedProps); }
public void ShouldReadEmptyObject() { var reader = new PropertyReader(); var properties = reader.Properties(new object()); Assert.That(properties, Is.Not.Null); Assert.That(properties.Count, Is.EqualTo(0)); }
public void ShouldReadPropertyValueNull() { var reader = new PropertyReader(); var properties = reader.Properties(new { Foo = 1, Bar = (string)null }); Assert.That(properties, Is.Not.Null); Assert.That(properties.Count, Is.EqualTo(2)); Assert.That(properties["Foo"], Is.EqualTo("1")); Assert.That(properties["Bar"], Is.Null); }
public void ShouldReadPropertiesOfAnonObject() { var reader = new PropertyReader(); var properties = reader.Properties(new { Foo = 1, Bar = "Two" }); Assert.That(properties, Is.Not.Null); Assert.That(properties.Count, Is.EqualTo(2)); Assert.That(properties["Foo"], Is.EqualTo("1")); Assert.That(properties["Bar"], Is.EqualTo("Two")); }
public static void GeneratesActionUrl(RouteCollection routes, string expectedUrl, object fromProps, HttpMethod httpMethod = null, string appPath = "/", string requestBody = null) { if (httpMethod == null) { httpMethod = HttpMethod.Get; } var propertyReader = new PropertyReader(); var expectedProps = propertyReader.Properties(fromProps); WebRouteAssert.GeneratesActionUrl(routes, httpMethod, expectedUrl, expectedProps, appPath, requestBody); }
public static void HasRoute(RouteCollection routes, string url, string body, object expectations) { var propertyReader = new PropertyReader(); var expectedProps = propertyReader.Properties(expectations); HasRoute(routes, url, body, expectedProps); }
public void ShouldNotReadNullObject() { var reader = new PropertyReader(); Assert.Throws<ArgumentNullException>(() => reader.Properties(null)); }