public void That_HaveTwoBooleanInsideAssertBlock_BothConditionsAreTested()
        {
            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var b1 = DummyCreator.GetTrueValue();
            var b2 = DummyCreator.GetFalseValue();

            Expect.That(() => b1 && b2);

            A.CallTo(() => fakeBuilder.GetIsTrueAction(A <Expression> ._, A <string> ._)).MustHaveHappened(Repeated.Exactly.Twice);
        }
        public void That_NullableBoolAndPassEqualToNullableBool_TransformToAssertNotEqual(bool?value, bool?expected)
        {
            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var assertAreEqualValidator = new CallValidator();

            A.CallTo(() => fakeBuilder.GetAreNotEqualAction(A <Expression> ._, A <Expression> ._, A <string> ._)).AddAssertValidation(assertAreEqualValidator);

            Expect.That(() => value != expected);

            assertAreEqualValidator.WasAssertCalledWithArguments(expected, value);
        }
예제 #3
0
        public void That_StringEndssWithCalled_StringAssertStartsWithUsed()
        {
            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var validator = new CallValidator();

            A.CallTo(() => fakeBuilder.GetStringEndsWith(A <Expression> ._, A <Expression> ._, A <string> ._)).AddAssertValidation(validator);

            Expect.That(() => "1234".EndsWith("2"));

            validator.WasAssertCalledWithArguments("2", "1234");
        }
        public void That_CheckIfArrayConatainsElement_CollectionAssertContainsCalled()
        {
            var collection = new[] { 1, 2, 3, 4, 5 };

            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var validator = new CallValidator();

            A.CallTo(() => fakeBuilder.GetCollectionContains(A <Expression> ._, A <Expression> ._, A <string> ._)).AddAssertValidation(validator);

            Expect.That(() => collection.Contains(7));

            validator.WasAssertCalledWithArguments(collection, 7);
        }
예제 #5
0
        public void That_PassLeftValueNotEqualToTrue_AssertFalseIsCalled()
        {
            var value = DummyCreator.GetTrueValue();

            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var validator = new CallValidator();

            A.CallTo(() => fakeBuilder.GetIsFalseAction(A <Expression> ._, A <string> ._)).AddAssertValidation(validator);

            Expect.That(() => value != true);

            validator.WasAssertCalledWithArguments(value);
        }
예제 #6
0
        public void That_NullableBoolAndPassEqualToFalseValue_AreEqualCalled()
        {
            var value = (bool?)DummyCreator.GetTrueValue();

            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var validator = new CallValidator();

            A.CallTo(() => fakeBuilder.GetAreEqualAction(A <Expression> ._, A <Expression> ._, A <string> ._)).AddAssertValidation(validator);

            Expect.That(() => value == false);

            validator.WasAssertCalledWithArguments <bool?, bool?>(false, value);
        }
예제 #7
0
        public void That_UseIsToCheckType_AssertIsInstaceOfCalled()
        {
            var val = DummyCreator.GetDummy();

            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var validator = new CallValidator();

            A.CallTo(() => fakeBuilder.GetIsInstanceOf(A <Type> ._, A <Expression> ._, A <string> ._)).AddAssertValidation(validator);

            Expect.That(() => val is string);

            validator.WasAssertCalledWithArguments(typeof(string), val);
        }
예제 #8
0
        public void That_CompareValueNotEqualToNullReversed_AssertIsNullCalled()
        {
            object val = null;

            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var validator = new CallValidator();

            A.CallTo(() => fakeBuilder.GetIsNotNullAction(A <Expression> ._, A <string> ._)).AddAssertValidation(validator);

            Expect.That(() => null != val);

            validator.WasAssertCalledWithArguments(val);
        }
예제 #9
0
        public void That_NullableBoolAndPassEqualToNull_AssertIsNullCalled()
        {
            var value = (bool?)null;

            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var validator = new CallValidator();

            A.CallTo(() => fakeBuilder.GetIsNullAction(A <Expression> ._, A <string> ._)).AddAssertValidation(validator);

            Expect.That(() => value == null);

            validator.WasAssertCalledWithArguments(value);
        }
예제 #10
0
        public void That_CheckIfArrayEqualsToArray_CollectionEqualsCalled()
        {
            var collection1 = new [] { 1, 2, 3, 4, 5 };
            var collection2 = new[] { 1, 2, 3, 4, 6 };

            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var validator = new CallValidator();

            A.CallTo(() => fakeBuilder.GetCollectionEquals(A <Expression> ._, A <Expression> ._, A <string> ._)).AddAssertValidation(validator);

            Expect.That(() => collection1 == collection2);

            validator.WasAssertCalledWithArguments(collection2, collection1);
        }
예제 #11
0
        public void That_PassTwoDoubleValuesWithNotEqualSign_TransformToAssertNotEqual()
        {
            var value    = DummyCreator.GetDouble();
            var expected = value;

            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var assertAreEqualValidator = new CallValidator();

            A.CallTo(() => fakeBuilder.GetAreNotEqualAction(A <Expression> ._, A <Expression> ._, A <string> ._)).AddAssertValidation(assertAreEqualValidator);

            Expect.That(() => value != expected);

            assertAreEqualValidator.WasAssertCalledWithArguments(expected, value);
        }
        public void That_HaveThreeBooleanInsideAssertBlock_BothConditionsAreTested()
        {
            AssertBuilderFactoryForTests.FakeAssertBuilder();


            var b1 = DummyCreator.GetTrueBooleanValue();
            var b2 = DummyCreator.GetTrueBooleanValue();
            var b3 = DummyCreator.GetTrueBooleanValue();

            Expect.That(() => b1 && b2 && b3);

            var assertBuilder = AssertBuilderFactory.GetAssertBuilder();

            A.CallTo(() => assertBuilder.GetIsTrueAction(A <Expression> ._, A <string> ._)).MustHaveHappened(Repeated.Exactly.Times(3));
        }
        public void That_HaveOneEqualityAndOneBooleanInsideAssertBlock_BothConditionsAreTested()
        {
            var fakeBuilder = AssertBuilderFactoryForTests.FakeAssertBuilder();

            var assertIsTrueValidor     = new CallValidator();
            var assertAreEqualValidator = new CallValidator();

            A.CallTo(() => fakeBuilder.GetIsTrueAction(A <Expression> ._, A <string> ._)).AddAssertValidation(assertIsTrueValidor);
            A.CallTo(() => fakeBuilder.GetAreEqualAction(A <Expression> ._, A <Expression> ._, A <string> ._)).AddAssertValidation(assertAreEqualValidator);

            var obj1 = DummyCreator.GetReferenceObject1();
            var obj2 = DummyCreator.GetReferenceObject2();
            var b1   = DummyCreator.GetTrueBooleanValue();

            Expect.That(() => obj1 == obj2 && b1);

            assertIsTrueValidor.WasAssertCalledWithArguments(b1);
            assertAreEqualValidator.WasAssertCalledWithArguments(obj2, obj1);
        }
예제 #14
0
 public void RestoreAssertBuilder()
 {
     AssertBuilderFactoryForTests.Restore();
 }