Пример #1
0
        public void Equals__Given_IsEqual__Then_True(TestJsonObject obj)
        {
            // Assemble
            var token1 = JObject.FromObject(obj);
            var token2 = JObject.Parse(JsonConvert.SerializeObject(obj));

            var subject = new LooseJsonEqualityComparer();

            // Act
            var result = subject.Equals(token1, token2);

            // Assert
            Assert.True(result);
            Assert.False(JToken.DeepEquals(token1, token2));
        }
Пример #2
0
        public void Equals__Given_NotEqual_String__Then_False(TestJsonObject obj)
        {
            // Assemble
            var token1 = JObject.FromObject(obj);

            obj.String = Guid.NewGuid().ToString();
            var token2 = JObject.Parse(JsonConvert.SerializeObject(obj));

            var subject = new LooseJsonEqualityComparer();

            // Act
            var result = subject.Equals(token1, token2);

            // Assert
            Assert.False(result);
            Assert.False(JToken.DeepEquals(token1, token2));
        }
Пример #3
0
        public void Equals__Given_NotEqual_AddedChildren__Then_False(TestJsonObject obj)
        {
            // Assemble
            var token1 = JObject.FromObject(obj);

            obj.OtherChildren.Add(new TestJsonObjectChild());
            var token2 = JObject.Parse(JsonConvert.SerializeObject(obj));

            var subject = new LooseJsonEqualityComparer();

            // Act
            var result = subject.Equals(token1, token2);

            // Assert
            Assert.False(result);
            Assert.False(JToken.DeepEquals(token1, token2));
        }