Esempio n. 1
0
        private void DeserializeVersionClass(string version1, string version2)
        {
            string  json             = string.Format(@"{{""StringProperty1"": ""StringProperty1"", ""Version1"": ""{0}"", ""Version2"": ""{1}"", ""StringProperty2"": ""StringProperty2""}}", version1, version2);
            Version expectedVersion1 = new Version(version1);
            Version expectedVersion2 = new Version(version2);

            VersionClass versionClass = JsonConvert.DeserializeObject <VersionClass>(json, new VersionConverter());

            Assert.AreEqual("StringProperty1", versionClass.StringProperty1);
            Assert.AreEqual(expectedVersion1, versionClass.Version1);
            Assert.AreEqual(expectedVersion2, versionClass.Version2);
            Assert.AreEqual("StringProperty2", versionClass.StringProperty2);
        }
Esempio n. 2
0
        private void SerializeVersionClass(string version1, string version2)
        {
            VersionClass versionClass = new VersionClass(version1, version2);

            string json = JsonConvert.SerializeObject(versionClass, Formatting.Indented, new VersionConverter());

            string expectedJson = string.Format(@"{{
  ""StringProperty1"": ""StringProperty1"",
  ""Version1"": ""{0}"",
  ""Version2"": ""{1}"",
  ""StringProperty2"": ""StringProperty2""
}}", version1, version2);

            Assert.AreEqual(expectedJson, json);
        }
Esempio n. 3
0
    private void SerializeVersionClass(string version1, string version2)
    {
      VersionClass versionClass = new VersionClass(version1, version2);

      string json = JsonConvert.SerializeObject(versionClass, Formatting.Indented, new VersionConverter());

      string expectedJson = string.Format(@"{{
  ""StringProperty1"": ""StringProperty1"",
  ""Version1"": ""{0}"",
  ""Version2"": ""{1}"",
  ""StringProperty2"": ""StringProperty2""
}}", version1, version2);

      Assert.AreEqual(expectedJson, json);
    }