Example #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            TestJson objAsTestJson = obj as TestJson;

            if (objAsTestJson == null)
            {
                return(false);
            }
            return(this.Name == objAsTestJson.Name &&
                   this.Count == objAsTestJson.Count);
        }
Example #2
0
        public void ObjectToJsonConvertTest()
        {
            // arrange
            TestJson json1 = new TestJson
            {
                Name  = "name1",
                Count = 5
            };
            JObject jo1 = JObject.FromObject(json1);

            // act
            TestJson json2 = JsonConvert.DeserializeObject <TestJson>(jo1.ToString());

            // assert
            Assert.AreEqual <TestJson>(json1, json2);
        }