public void WhenSerializedContainsExpectedValue() { var person = new Person { Name = "John Smith", Address = new Address { AddressLine1 = "1 Some Street" } }; var converter = new JsonValueConverter <Person>(); var serialized = (string)converter.ConvertToProvider(person); serialized.Should().BeEquivalentTo(_json, serialized); }
public void ApplyCustomJsonConverter() { var customer = new Customer { ProtectedAddress = new Address { Street = "Privet Drive 4" } }; var converter = new JsonValueConverter <Customer>(); var serialized = (string)converter.ConvertToProvider(customer); Assert.IsFalse(serialized.Contains("Privet"), "Serialization applied custom converter"); var deserialized = (Customer)converter.ConvertFromProvider(serialized); Assert.AreEqual("Privet Drive 4", deserialized.ProtectedAddress.Street, "Deserialization applied custom converter"); }