public void LoadFromObjectWithCollections() { var source = new ObjectWithRepeatedFieldsTestClass { A = new List <int> { 1, 2 }, B = new HashSet <string> { "set1", "set2" }, C = new HashSet <int> { 1, 2 }, D = new List <double> { 0.1, 1.0 }, E = new List <bool> { true, false } }; var expected = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("A", "01"), new KeyValuePair <string, string>("A", "02"), new KeyValuePair <string, string>("B", "set1,set2"), new KeyValuePair <string, string>("C", "01 02"), new KeyValuePair <string, string>("D", "0.10\t1.00"), // The default behavior is to capitalize booleans. This is not a requirement. new KeyValuePair <string, string>("E", "True|False") }; var actual = new FormValueMultimap(source, settings); Assert.Equal(expected, actual); }
public void DefaultCollectionFormatCanBeSpecifiedInSettings() { var settingsWithCollectionFormat = new RefitSettings { CollectionFormat = CollectionFormat.Multi }; var source = new ObjectWithRepeatedFieldsTestClass { // Members have explicit CollectionFormat A = new List <int> { 1, 2 }, B = new HashSet <string> { "set1", "set2" }, C = new HashSet <int> { 1, 2 }, D = new List <double> { 0.1, 1.0 }, E = new List <bool> { true, false }, // Member has no explicit CollectionFormat F = new[] { 1, 2, 3 } }; var expected = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("A", "01"), new KeyValuePair <string, string>("A", "02"), new KeyValuePair <string, string>("B", "set1,set2"), new KeyValuePair <string, string>("C", "01 02"), new KeyValuePair <string, string>("D", "0.10\t1.00"), new KeyValuePair <string, string>("E", "True|False"), new KeyValuePair <string, string>("F", "1"), new KeyValuePair <string, string>("F", "2"), new KeyValuePair <string, string>("F", "3"), }; var actual = new FormValueMultimap(source, settingsWithCollectionFormat); Assert.Equal(expected, actual); }