public void Complex_object_array_should_return_expected_string() { var builder = new Builder(); var obj = new { a = new { b = 1, c = 2 }, d = new object[] { 3, 4, new { e = 5 } } }; var result = builder.ToQueryString(obj); result.ShouldBe("?a[b]=1&a[c]=2&d[]=3&d[]=4&d[2][e]=5"); }
public void Array_of_objects_should_return_expected_results() { var args = new { batch = new[] { new { EMAIL = "*****@*****.**", EMAIL_TYPE = "text" }, new { EMAIL = "*****@*****.**", EMAIL_TYPE = "html" }, new { EMAIL = "*****@*****.**", EMAIL_TYPE = "html" }, new { EMAIL = "*****@*****.**", EMAIL_TYPE = "html" }, }, }; var builder = new Builder(); var result = builder.ToQueryString(args); result.ShouldBe("?batch[0][EMAIL]=blah-dee%40gmail.com&batch[0][EMAIL_TYPE]=text&batch[1][EMAIL]=herp-derp%40gmail.com&batch[1][EMAIL_TYPE]=html&batch[2][EMAIL]=something%40gmail.com&batch[2][EMAIL_TYPE]=html&batch[3][EMAIL]=adksfjkdlsjf%40gmail.com&batch[3][EMAIL_TYPE]=html"); }
public void ObjectWithChildObject_with_many_descendants_should_return_expected_string() { var build = new Builder(); var obj = new { Atmosphere = new { Crust = new { UpperMantle = new { TransitionZone = new { LowerMantle = new { OuterCore = new { InnerCore = "hot", } } } } } } }; var result = build.ToQueryString(obj); result.ShouldBe("?Atmosphere[Crust][UpperMantle][TransitionZone][LowerMantle][OuterCore][InnerCore]=hot"); }
public void Objects_with_null_values_are_handled_by_default() { var builder = new Builder(); var mixedObj = new MixedObject { TextMessage = null }; var obj = new { Id = mixedObj.TextMessage, Name = "test" }; var result = builder.ToQueryString(obj); result.ShouldBe("?Id=&Name=test"); }