Example #1
0
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();

            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.True(Are.EqualInTermsOfEqualityOperator(_activator.TargetType, instance1, instance1),
                                                                    "a == a should return true", violations), "a == a should return true", violations);
        }
Example #2
0
        public bool HasAttribute <T>(T expectedAttribute) where T : Attribute
        {
            var attrs = Attribute.GetCustomAttributes(_methodInfo, typeof(T));
            var any   = attrs.Any(
                currentAttribute => Are.Alike(expectedAttribute, currentAttribute)
                );

            return(any);
        }
Example #3
0
        public bool HasAttribute(Type attributeType, Attribute expectedAttribute)
        {
            var attrs = Attribute.GetCustomAttributes(_methodInfo, attributeType);
            var any   = attrs.Any(
                currentAttribute => Are.Alike(expectedAttribute, currentAttribute)
                );

            return(any);
        }
 public void CheckAndRecord(ConstraintsViolations violations)
 {
     foreach (var factory in _equalInstances.Concat(_otherInstances))
     {
         var instance = factory();
         RecordedAssertions.DoesNotThrow(() =>
                                         RecordedAssertions.False(Are.NotEqualInTermsOfInEqualityOperator(typeof(T), instance, instance),
                                                                  "a != a should return false", violations),
                                         "a != a should return false", violations);
     }
 }
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();
            var instance2 = _activator.CreateInstanceAsValueObjectWithPreviousParameters();

            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.False(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, instance1, instance2),
                                                                     "a != b should return false if both are created with the same arguments", violations),
                                            "a != b should return false if both are created with the same arguments", violations);
            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.False(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, instance2, instance1),
                                                                     "b != a should return false if both are created with the same arguments", violations),
                                            "b != a should return false if both are created with the same arguments", violations);
        }
Example #6
0
 public void CheckAndRecord(ConstraintsViolations violations)
 {
     foreach (var factory1 in _equalInstances)
     {
         foreach (var factory2 in _otherInstances)
         {
             RecordedAssertions.DoesNotThrow(() =>
                                             RecordedAssertions.True(Are.NotEqualInTermsOfInEqualityOperator(typeof(T), factory1(), factory2()),
                                                                     "a != b should return true if they are not equal", violations),
                                             "a != b should return true if they are not equal", violations);
             RecordedAssertions.DoesNotThrow(() =>
                                             RecordedAssertions.True(Are.NotEqualInTermsOfInEqualityOperator(typeof(T), factory1(), factory2()),
                                                                     "b != a should return true if if they are not equal", violations),
                                             "b != a should return true if if they are not equal", violations);
         }
     }
 }
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            foreach (var factory in _equalInstances)
            {
                var instance1 = factory();
                var instance2 = factory();

                RecordedAssertions.DoesNotThrow(() =>
                                                RecordedAssertions.False(Are.NotEqualInTermsOfInEqualityOperator(typeof(T), instance1, instance2),
                                                                         "a != b should return false for equal values", violations),
                                                "a != b should return false for equal values", violations);
                RecordedAssertions.DoesNotThrow(() =>
                                                RecordedAssertions.False(Are.NotEqualInTermsOfInEqualityOperator(typeof(T), instance2, instance1),
                                                                         "b != a should return false for equal values", violations),
                                                "b != a should return false for equal values", violations);
            }
        }
 public void CheckAndRecord(ConstraintsViolations violations)
 {
     foreach (var factory1 in _equalInstances)
     {
         foreach (var factory2 in _otherInstances)
         {
             RecordedAssertions.DoesNotThrow(() =>
                                             RecordedAssertions.False(Are.EqualInTermsOfEqualityOperator(typeof(T), factory1(), factory2()),
                                                                      "a == b should return false for not equal values", violations),
                                             "a == b should return false for not equal values", violations
                                             );
             RecordedAssertions.DoesNotThrow(() =>
                                             RecordedAssertions.False(Are.EqualInTermsOfEqualityOperator(typeof(T), factory2(), factory1()),
                                                                      "b == a should return false for not equal values", violations),
                                             "b == a should return false for not equal values", violations
                                             );
         }
     }
 }
Example #9
0
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            if (!typeof(T).IsValueType)
            {
                foreach (var factory in _equalInstances.Concat(_otherInstances))
                {
                    var instance1 = factory();
                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.False(Are.EqualInTermsOfEqualityOperator(typeof(T), instance1, null),
                                                                             "a == null should return false", violations),
                                                    "a == null should return false", violations);

                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.False(Are.EqualInTermsOfEqualityOperator(typeof(T), null, instance1),
                                                                             "null == a should return false", violations),
                                                    "null == a should return false", violations);
                }
            }
        }
Example #10
0
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            foreach (var factory1 in _equalInstances)
            {
                foreach (var factory2 in _equalInstances)
                {
                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.True(Are.EqualInTermsOfEqualityOperator(typeof(T), factory1(), factory2()),
                                                                            "a == b should return true if both are created with the same arguments that define equality", violations),
                                                    "a == b should return true if both are created with the same arguments that define equality", violations
                                                    );

                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.True(Are.EqualInTermsOfEqualityOperator(typeof(T), factory2(), factory1()),
                                                                            "b == a should return true if both are created with the same arguments that define equality", violations),
                                                    "b == a should return true if both are created with the same arguments that define equality", violations
                                                    );
                }
            }
        }
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();

            for (var i = 0; i < _activator.GetConstructorParametersCount(); ++i)
            {
                if (ArgumentIsPartOfValueIdentity(i))
                {
                    var instance2 = _activator.CreateInstanceAsValueObjectWithModifiedParameter(i);

                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.True(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, instance1, instance2),
                                                                            "a != b should return true if both are created with different argument" + i, violations),
                                                    "a != b should return true if both are created with different argument" + i, violations);
                    RecordedAssertions.DoesNotThrow(() =>
                                                    RecordedAssertions.True(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, instance1, instance2),
                                                                            "b != a should return true if both are created with different argument" + i, violations),
                                                    "b != a should return true if both are created with different argument" + i, violations);
                }
            }
        }
Example #12
0
        public void CheckAndRecord(ConstraintsViolations violations)
        {
            var instance1 = _activator.CreateInstanceAsValueObjectWithFreshParameters();

            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.True(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, instance1, null),
                                                                    "a != null should return true", violations),
                                            "a != null should return true", violations);
            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.True(Are.NotEqualInTermsOfInEqualityOperator(_activator.TargetType, null, instance1),
                                                                    "null != a should return true", violations),
                                            "null != a should return true", violations);

            //TODO remove?
            object null1 = null;
            object null2 = null;

            RecordedAssertions.DoesNotThrow(() =>
                                            RecordedAssertions.False(null1 != null2,
                                                                     "null != null should be false", violations),
                                            "null != null should be false", violations);
        }
Example #13
0
 public static T IsLike <T>(T expected)
 {
     return(Arg.Is <T>(arg => Are.Alike(expected, arg)));
 }
Example #14
0
            public void Returns_Clause_Containing_The_Word_And_Once_For_Two_Clauses()
            {
                var clause = Are.AreAllOfTheseTrue(Column.Named("Foo").IsEqualTo(12), Column.Named("Bar").IsGreaterThan("asdf"));

                StringAssert.Contains(clause.ToString(), "AND");
            }
Example #15
0
            public void Returns_Clause_With_Two_Ands_For_Three_Clauses()
            {
                var clause = Are.AreAllOfTheseTrue(Column.Named("Foo").IsEqualTo(12), Column.Named("Bar").IsGreaterThan("asdf"), Column.Named("Baz").IsLessThan(4.2));

                Assert.AreEqual <int>(3, Regex.Split(clause.ToString(), "AND").Count());
            }
Example #16
0
            public void Returns_Object_With_Two_Ors_For_Three_Parameters()
            {
                var clause = Are.AnyOfTheseTrue(Column.Named("Foo").IsEqualTo(12), Column.Named("Bar").IsGreaterThan("asdf"), Column.Named("Baz").IsLessThan(4.2));

                Assert.AreEqual <int>(3, Regex.Split(clause.ToString(), "OR").Count());
            }
Example #17
0
            public void Returns_Clause_With_Word_Or_In_It()
            {
                var clause = Are.AnyOfTheseTrue(Column.Named("Foo").IsEqualTo(12), Column.Named("Bar").IsGreaterThan("asdf"));

                StringAssert.Contains(clause.ToString(), "OR");
            }
Example #18
0
            public void Returns_Or_Object()
            {
                var clause = Are.AnyOfTheseTrue(Column.Named("Foo").IsEqualTo(12), Column.Named("Bar").IsGreaterThan("asdf"));

                Assert.IsInstanceOfType(clause, typeof(Or));
            }