public void Read() { // Arrange var json = "{ \"some_value\": \"QWERTY\", \"another_value\": \"ABC_123\" }"; var textReader = new StringReader(json); var jsonReader = new JsonTextReader(textReader); var objectType = typeof(KeyValuePair <string, string>[]); var existingValue = (object)null; var serializer = new JsonSerializer(); var converter = new KeyValuePairEnumerationConverter(); // Act jsonReader.Read(); var result = converter.ReadJson(jsonReader, objectType, existingValue, serializer); // Assert result.ShouldNotBeNull(); result.ShouldBeOfType <KeyValuePair <string, string>[]>(); var resultAsArray = (KeyValuePair <string, string>[])result; resultAsArray.Length.ShouldBe(2); resultAsArray[0].Key.ShouldBe("some_value"); resultAsArray[0].Value.ShouldBe("QWERTY"); resultAsArray[1].Key.ShouldBe("another_value"); resultAsArray[1].Value.ShouldBe("ABC_123"); }
public void Read() { // Arrange var json = ""; var textReader = new StringReader(json); var jsonReader = new JsonTextReader(textReader); var objectType = (Type)null; var existingValue = (object)null; var serializer = new JsonSerializer(); var converter = new KeyValuePairEnumerationConverter(); // Act jsonReader.Read(); Should.Throw <NotImplementedException>(() => converter.ReadJson(jsonReader, objectType, existingValue, serializer)); }