예제 #1
0
        public void ApplyTo_DifferentCollections_Fails()
        {
            EnumerableEqualsConstraint constraint = new EnumerableEqualsConstraint(new[] { 1, 2, 3, 4, 5 });
            ConstraintResult           result     = constraint.ApplyTo(new[] { 1, 2, 2, 4, 5 });

            Assert.That(result, Has.Property <ConstraintResult>(r => r.IsSuccess).False, result.ToString());
            Assert.That(result.ToString(), Is.EqualTo("  Expected: element at [2] to be: 3\r\n  But was:  2\r\n"));
        }
예제 #2
0
        public void ApplyTo_DifferentJArrays_Fails()
        {
            JsonEqualsConstraint constraint = new JsonEqualsConstraint(JArray.FromObject(new [] { "ONE", "TWO", "THREE", "FOUR" }))
                                              .AllowArrayOutOfOrder();
            ConstraintResult result = constraint.ApplyTo(JArray.FromObject(new[] { "ONE", "TWO", "FOUR", "FIVE" }));

            Assert.That(result, Has.Property <ConstraintResult>(r => r.IsSuccess).False, result.ToString());

            string str = result.ToString();

            Assert.That(result.ToString(), Is.EqualTo("JTokens did not match." +
                                                      "\r\n  Value at '' was not equals." +
                                                      "\r\n    Expected: <missing>" +
                                                      "\r\n    But was:  THREE" +
                                                      "\r\n" +
                                                      "\r\n  Value at '' was not equals." +
                                                      "\r\n    Expected: FIVE" +
                                                      "\r\n    But was:  <extra>" +
                                                      "\r\n" +
                                                      "\r\n"));
        }
예제 #3
0
        public void ApplyTo_DifferentJObjects_Fails()
        {
            JsonEqualsConstraint constraint = new JsonEqualsConstraint(JObject.FromObject(new { Name = "FOO" }));
            ConstraintResult     result     = constraint.ApplyTo(JObject.FromObject(new { Name = "FOX" }));

            Assert.That(result, Has.Property <ConstraintResult>(r => r.IsSuccess).False, result.ToString());

            Assert.That(result.ToString(), Is.EqualTo("JTokens did not match." +
                                                      "\r\n  Value at 'Name' was not equals." +
                                                      "\r\n    Expected: FOX" +
                                                      "\r\n    But was:  FOO\r\n\r\n"));
        }
예제 #4
0
        public void ApplyTo_DifferentCollections_Fails()
        {
            var constraint          = Has.Properties.EqualTo(new { Test = "222" });
            ConstraintResult result = constraint.ApplyTo(new { Test = "243" });

            Assert.That(result, Has.Property <ConstraintResult>(r => r.IsSuccess).False, result.ToString());
            Assert.That(result.ToString(), Is.EqualTo("Properties of the object did not match." +
                                                      "\r\n  The property 'Test <System.String>' was not equals." +
                                                      "\r\n    String lengths are both 3. Strings differ at index 1." +
                                                      "\r\n    Expected: \"222\"" +
                                                      "\r\n    But was:  \"243\"" +
                                                      "\r\n    ------------^" +
                                                      "\r\n  " +
                                                      "\r\n"));
        }
예제 #5
0
        public void ApplyTo_EquivalentCollections_Passes()
        {
            EnumerableEqualsConstraint constraint = new EnumerableEqualsConstraint(new [] { 1, 2, 3, 4, 5 });
            ConstraintResult           result     = constraint.ApplyTo(new[] { 1, 2, 3, 4, 5 });

            Assert.That(result, Has.Property <ConstraintResult>(r => r.IsSuccess).True, result.ToString());
        }
예제 #6
0
        public void ApplyTo_MultiplePropertiesOneNotEqualStrict_Fails()
        {
            var constraint          = Has.Properties.NotEqualTo(new { Test = "243", Age = 42 }).Strict();
            ConstraintResult result = constraint.ApplyTo(new { Test = "244", Age = 42 });

            Assert.That(result, Has.Property <ConstraintResult>(r => r.IsSuccess).False, result.ToString());
        }
예제 #7
0
        public void ApplyTo_SinglePropertyNotEqual_Passes()
        {
            var constraint          = Has.Properties.NotEqualTo(new { Test = "243" });
            ConstraintResult result = constraint.ApplyTo(new { Test = "244" });

            Assert.That(result, Has.Property <ConstraintResult>(r => r.IsSuccess).True, result.ToString());
        }
예제 #8
0
        public void ApplyTo_EquivalentCollections_Passes()
        {
            var constraint          = Has.Properties.EqualTo(new { Test = "243" });
            ConstraintResult result = constraint.ApplyTo(new { Test = "243" });

            Assert.That(result, Has.Property <ConstraintResult>(r => r.IsSuccess).True, result.ToString());
        }
예제 #9
0
        public void ApplyTo_EquivalentJObjects_Passes()
        {
            JsonEqualsConstraint constraint = new JsonEqualsConstraint(JObject.FromObject(new { Name = "FOO" }));
            ConstraintResult     result     = constraint.ApplyTo(JObject.FromObject(new { Name = "FOO" }));

            Assert.That(result, Has.Property <ConstraintResult>(r => r.IsSuccess).True, result.ToString());
        }