public void Serialize(Extremum extremum) { var json = JsonConvert.SerializeObject(extremum); var actual = JsonConvert.DeserializeObject <Extremum>(json); Assert.NotNull(actual); Assert.AreEqual(extremum.GetType(), actual.GetType()); }
public void Deserialize(string extremum) { var actual = JsonConvert.DeserializeObject <Extremum>(extremum); Extremum expected = extremum.Equals("\"max\"", StringComparison.OrdinalIgnoreCase) ? new Maximization() as Extremum : new Minimization(); Assert.NotNull(actual); Assert.AreEqual(expected.GetType(), actual.GetType()); }