public void SerializeVersionClass_Null()
        {
            VersionClass versionClass = new VersionClass();
            versionClass.VersionValue = null;

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

            Assert.AreEqual(@"{
              ""VersionValue"": null
            }", json);
        }
        public void SerializeVersionClass_MajorMinorBuildRevision()
        {
            VersionClass versionClass = new VersionClass();
            versionClass.VersionValue = new Version(1, 2, 3, 4);

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

            Assert.AreEqual(@"{
              ""VersionValue"": ""1.2.3.4""
            }", json);
        }
Exemple #3
0
        public void SerializeVersionClass_Null()
        {
            VersionClass versionClass = new VersionClass();

            versionClass.VersionValue = null;

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

            Assert.AreEqual(@"{
  ""VersionValue"": null
}", json);
        }
Exemple #4
0
        public void SerializeVersionClass_MajorMinor()
        {
            VersionClass versionClass = new VersionClass();

            versionClass.VersionValue = new Version(1, 2);

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

            Assert.AreEqual(@"{
  ""VersionValue"": ""1.2""
}", json);
        }
Exemple #5
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);
        }
    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"",
  ""StringProperty2"": ""StringProperty2"",
  ""Version1"": ""{0}"",
  ""Version2"": ""{1}""
}}", version1, version2);

      Assert.AreEqual(expectedJson, json);
    }
Exemple #7
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);
        }