public async Task When_TypeConverter_Exists_Then_Array_Populated() { // Arrange var lengths = new [] { new Length { Value = 14, Unit = Unit.cm, }, new Length { Value = 89, Unit = Unit.mm, }, }; var expected = new QueryTestOperation { Lengths = lengths, }; // Act / Assert await AssertPopulatedFromQueryString( expected, $"?{nameof(expected.Lengths)}[]={lengths[0]}&{nameof(expected.Lengths)}[]={lengths[1]}"); }
public async Task When_Array_Like_As_Separate_Values_Then_Populates() { // Arrange var source = new List <string> { "arr1", "arr5" }; string AsQuery(string key) { return($"{key}[]=arr1&{key}[]=arr5"); } var expected = new QueryTestOperation { StringArray = source.ToArray(), StringEnumerable = source, StringList = source, }; // Act / Assert await AssertPopulatedFromQueryString( expected, $"?{AsQuery(nameof(expected.StringArray))}&" + $"{AsQuery(nameof(expected.StringEnumerable))}&" + $"{AsQuery(nameof(expected.StringList))}"); }
public async Task When_TypeConverter_Exists_Then_Populated() { // Arrange var expected = new QueryTestOperation { Length = new Length { Value = 154, Unit = Unit.cm, }, }; // Act / Assert await AssertPopulatedFromQueryString( expected, $"?{nameof(expected.Length)}={expected.Length}"); }
public async Task When_Simple_Properties_Then_Populated() { // Arrange var expected = new QueryTestOperation { IntegerProperty = 761, EnumProperty = OperationEnum.EnumOne, GuidProperty = Guid.NewGuid(), StringProperty = "a string", NullableIntegerProperty = null }; // Act / Assert await AssertPopulatedFromQueryString( expected, $"?{nameof(expected.IntegerProperty)}={expected.IntegerProperty}&" + $"{nameof(expected.EnumProperty)}={expected.EnumProperty}&" + $"{nameof(expected.GuidProperty)}={expected.GuidProperty}&" + $"{nameof(expected.StringProperty)}={expected.StringProperty}"); }