Exemplo n.º 1
0
        public void JsonMatcher_IsMatch_WithInvalidValue_And_ThrowExceptionIsTrue_Should_ReturnMismatch()
        {
            // Assign
            var matcher = new JsonMatcher("", false, true);

            // Act
            Action action = () => matcher.IsMatch(new MemoryStream());

            // Assert
            action.Should().Throw <JsonException>();
        }
Exemplo n.º 2
0
        public void JsonMatcher_IsMatch_WithInvalidValue_And_ThrowExceptionIsFalse_Should_ReturnMismatch()
        {
            // Assign
            var matcher = new JsonMatcher("");

            // Act
            double match = matcher.IsMatch(new MemoryStream());

            // Assert
            Check.That(match).IsEqualTo(0);
        }
Exemplo n.º 3
0
        public void JsonMatcher_IsMatch_JObject2()
        {
            // Assign
            var matcher = new JsonMatcher(new { Id = 1, Name = "Test" });

            // Act
            var    jobject = JObject.Parse("{ \"Id\" : 1, \"Name\" : \"Test\" }");
            double match   = matcher.IsMatch(jobject);

            // Assert
            Assert.Equal(1.0, match);
        }
Exemplo n.º 4
0
        public void JsonMatcher_IsMatch_NullObject()
        {
            // Assign
            object o       = null;
            var    matcher = new JsonMatcher("");

            // Act
            double match = matcher.IsMatch(o);

            // Assert
            Check.That(match).IsEqualTo(0);
        }
Exemplo n.º 5
0
        public void JsonMatcher_IsMatch_NullString()
        {
            // Assign
            string s       = null;
            var    matcher = new JsonMatcher("");

            // Act
            double match = matcher.IsMatch(s);

            // Assert
            Check.That(match).IsEqualTo(0);
        }
Exemplo n.º 6
0
        public void JsonMatcher_IsMatch_ByteArray()
        {
            // Assign
            var bytes   = new byte[0];
            var matcher = new JsonMatcher("");

            // Act
            double match = matcher.IsMatch(bytes);

            // Assert
            Check.That(match).IsEqualTo(0);
        }
Exemplo n.º 7
0
        public void JsonMatcher_IsMatch_WithIgnoreCaseTrue_JObjectParsed()
        {
            // Assign
            var matcher = new JsonMatcher(new { Id = 1, Name = "TESt" }, true);

            // Act
            var    jobject = JObject.Parse("{ \"Id\" : 1, \"Name\" : \"Test\" }");
            double match   = matcher.IsMatch(jobject);

            // Assert
            Assert.Equal(1.0, match);
        }
Exemplo n.º 8
0
        public void JsonMatcher_IsMatch_JObjectWithDateTimeOffsetAsString()
        {
            // Assign
            var matcher = new JsonMatcher("{ \"preferredAt\" : \"2019-11-21T10:32:53.2210009+00:00\" }");

            // Act
            var jobject = new JObject
            {
                { "preferredAt", new JValue("2019-11-21T10:32:53.2210009+00:00") }
            };
            double match = matcher.IsMatch(jobject);

            // Assert
            Assert.Equal(1.0, match);
        }
Exemplo n.º 9
0
        public void JsonMatcher_IsMatch_JObjectAsString()
        {
            // Assign
            var matcher = new JsonMatcher("{ \"Id\" : 1, \"Name\" : \"Test\" }");

            // Act
            var jobject = new JObject
            {
                { "Id", new JValue(1) },
                { "Name", new JValue("Test") }
            };
            double match = matcher.IsMatch(jobject);

            // Assert
            Assert.Equal(1.0, match);
        }
Exemplo n.º 10
0
        public void JsonMatcher_IsMatch_JObject1()
        {
            // Assign
            var matcher = new JsonMatcher(new { Id = 1, Name = "Test" });

            // Act
            var jobject = new JObject
            {
                { "Id", new JValue(1) },
                { "Name", new JValue("Test") }
            };
            double match = matcher.IsMatch(jobject);

            // Assert
            Assert.Equal(1.0, match);
        }
Exemplo n.º 11
0
        public void JsonMatcher_IsMatch_JArray()
        {
            // Assign
            var matcher = new JsonMatcher(new[] { "x", "y" });

            // Act
            var jArray = new JArray
            {
                "x",
                "y"
            };
            double match = matcher.IsMatch(jArray);

            // Assert
            Assert.Equal(1.0, match);
        }
Exemplo n.º 12
0
        public void JsonMatcher_IsMatch_JArrayAsString()
        {
            // Assign
            var matcher = new JsonMatcher("[ \"x\", \"y\" ]");

            // Act
            var jArray = new JArray
            {
                "x",
                "y"
            };
            double match = matcher.IsMatch(jArray);

            // Assert
            Assert.Equal(1.0, match);
        }
Exemplo n.º 13
0
        public void JsonMatcher_IsMatch_WithIgnoreCaseTrue_JObject()
        {
            // Assign
            var matcher = new JsonMatcher(new { id = 1, Name = "test" }, true);

            // Act
            var jobject = new JObject
            {
                { "Id", new JValue(1) },
                { "NaMe", new JValue("Test") }
            };
            double match = matcher.IsMatch(jobject);

            // Assert
            Assert.Equal(1.0, match);
        }
Exemplo n.º 14
0
        public void JsonMatcher_IsMatch_JObject_RejectOnMatch()
        {
            // Assign
            var matcher = new JsonMatcher(MatchBehaviour.RejectOnMatch, "{ \"Id\" : 1, \"Name\" : \"Test\" }");

            // Act
            var jobject = new JObject
            {
                { "Id", new JValue(1) },
                { "Name", new JValue("Test") }
            };
            double match = matcher.IsMatch(jobject);

            // Assert
            Assert.Equal(0.0, match);
        }