public void ReasonsForDissatisfactionIsClearedBeforeSatisfactionIsEvaluated()
 {
     sut = new NotSpecification<string>(spec);
     spec.IsSatisfiedBy(TestString).Returns(true, false);
     Assert.IsFalse(sut.IsSatisfiedBy(TestString));
     Assert.IsTrue(sut.IsSatisfiedBy(TestString));
     Assert.AreEqual(0, sut.ReasonsForDissatisfaction.Count());
 }
Ejemplo n.º 2
0
        public void CanFilterByNotSpecification()
        {
            Specification <string> isLowercase        = new IsLowercaseSpecification();
            Specification <string> isNotJustLowercase = new NotSpecification <string>(isLowercase);

            Assert.IsTrue(isLowercase.IsSatisfiedBy("foo"));
            Assert.IsFalse(isLowercase.IsSatisfiedBy("Bar"));

            Assert.IsFalse(isNotJustLowercase.IsSatisfiedBy("foo"));
            Assert.IsTrue(isNotJustLowercase.IsSatisfiedBy("Bar"));
        }
Ejemplo n.º 3
0
        public void Not_Should_Reverse_SatisfiedBy_Value()
        {
            var s = new Mock <ISpecification <int> >();

            s.Setup(x => x.IsSatisfiedBy(5)).Returns(true);

            var not = new NotSpecification <int>(s.Object);

            Assert.IsFalse(not.IsSatisfiedBy(5));

            s.Setup(x => x.IsSatisfiedBy(6)).Returns(false);
            Assert.IsTrue(not.IsSatisfiedBy(6));
        }
 public void SpecificationIsSatisfiedWhenSpecIsNotSatisfied()
 {
     sut = new NotSpecification<string>(spec);
     spec.IsSatisfiedBy(TestString).Returns(false);
     Assert.IsTrue(sut.IsSatisfiedBy(TestString));
     Assert.AreEqual(0, sut.ReasonsForDissatisfaction.Count());
 }
 public void NotSpecification_IsSatisfiedBy_SpecificationTrue_False()
 {
     var mockRepository = new MockRepository(MockBehavior.Strict);
     var singleSpecification = mockRepository.CreateSpecificationMock<string>(true);
     var specification = new NotSpecification<string>(singleSpecification);
     Assert.AreEqual(false, specification.IsSatisfiedBy("test"));
     mockRepository.VerifyAll();
 }
                public When_First_Option_Is_False()
                {
                    option = new NotSpecification(
                        new FalseSpecification()
                    );

                    result = option.IsSatisfiedBy(new object());
                }
Ejemplo n.º 7
0
        public bool IsSatisfied_Reverses_Original_One(bool origResult)
        {
            var originalSpec = new DirectSpecification <object>(obj => origResult);

            var spec = new NotSpecification <object>(originalSpec);

            return(spec.IsSatisfiedBy(new object()));
        }
        public void IsSatisfiedByReturnsNegateOfPassedSpecification()
        {
            var otherSpecification = new Mock<ISpecification<object>>();
            otherSpecification.Setup<bool>(x => x.IsSatisfiedBy(It.IsAny<object>())).Returns(false);

            var specification = new NotSpecification<object>(otherSpecification.Object);
            Assert.True(specification.IsSatisfiedBy(string.Empty));
        }
Ejemplo n.º 9
0
        public void NotSpecification_Not_Test()
        {
            var notSpec = new NotSpecification <TestObjects.Member>(spec);

            member.City = "Moscow";

            Assert.That(!notSpec.IsSatisfiedBy(member));
        }
Ejemplo n.º 10
0
        public void Not_Should_Reverse_SatisfiedBy_Value()
        {
            var mocks = new MockRepository();
            var s     = mocks.StrictMock <ISpecification <int> >();

            Expect.Call(s.IsSatisfiedBy(5)).Return(true);
            Expect.Call(s.IsSatisfiedBy(6)).Return(false);

            mocks.ReplayAll();

            var not = new NotSpecification <int>(s);

            Assert.IsFalse(not.IsSatisfiedBy(5));
            Assert.IsTrue(not.IsSatisfiedBy(6));

            mocks.VerifyAll();
        }
Ejemplo n.º 11
0
        public void Not_Should_Reverse_SatisfiedBy_Value()
        {
            var mocks = new MockRepository();
            var s = mocks.StrictMock<ISpecification<int>>();

            Expect.Call(s.IsSatisfiedBy(5)).Return(true);
            Expect.Call(s.IsSatisfiedBy(6)).Return(false);

            mocks.ReplayAll();

            var not = new NotSpecification<int>(s);

            Assert.IsFalse(not.IsSatisfiedBy(5));
            Assert.IsTrue(not.IsSatisfiedBy(6));

            mocks.VerifyAll();
        }
        public void IsSatisfiedByReturnsTrueWhenSpecifactionIsFalse(TestObject testObject, bool result)
        {
            var specification1 = new ExpressionSpecification <TestObject>(p => p.BooleanProperty);

            var notSpecification = new NotSpecification <TestObject>(specification1);

            notSpecification.IsSatisfiedBy(testObject).ShouldBe(result);
        }
Ejemplo n.º 13
0
            public void WithAFailingSpecItShouldPass()
            {
                var specification = new FunctionSpecification<int>(i => i > 0);
                var sut = new NotSpecification<int>(specification);

                var result = sut.IsSatisfiedBy(1);

                result.Should().BeFalse();
            }
Ejemplo n.º 14
0
            public void WithAPassingSpecItShouldReturnAFail()
            {
                var specification = new FunctionSpecification<int>(i => i > 0);
                var sut = new NotSpecification<int>(specification);

                var result = sut.IsSatisfiedBy(0);

                result.Should().BeTrue();
            }
            public void NullCandidate_NoException()
            {
                var specification = MockComplexSpecification.True();
                var sut           = new NotSpecification <object>(specification);

                var exception = Record.Exception(() => sut.IsSatisfiedBy(null));

                Assert.Null(exception);
            }
            public void IncorrectData_ReturnFalse(bool isNegatable)
            {
                var specification = !isNegatable
                    ? MockComplexSpecification.True()
                    : MockNegatableComplexSpecification.True();

                var sut = new NotSpecification <object>(specification);

                var result = sut.IsSatisfiedBy(new object());

                Assert.False(result);
            }
            public void RelatedNegatableTypes_NoException()
            {
                var specification = MockNegatableComplexSpecification <IEnumerable <char> > .True();

                var exception = Record.Exception(() =>
                {
                    var sut = new NotSpecification <ChildFakeType>(specification);
                    sut.IsSatisfiedBy(new ChildFakeType());
                });

                Assert.Null(exception);
            }
Ejemplo n.º 18
0
        public void True_Equals_False()
        {
            // Arrange
            var trueSpec = new GenericSpecification(true);
            var notSpec  = new NotSpecification <TestAggregateRoot, long>(trueSpec);

            // Act
            var actualSpecResult = notSpec.IsSatisfiedBy(null);

            // Assert
            Assert.IsFalse(actualSpecResult);
        }
Ejemplo n.º 19
0
        public void NotSpecification_ShouldBeSatisfiedWhenUserNameIsEmpty()
        {
            var spec = new UsernameSpecification();

            var not = new NotSpecification <User>(spec);

            var user1 = new User {
                username = ""
            };

            not.IsSatisfiedBy(user1).Should().BeTrue();
        }
Ejemplo n.º 20
0
        public void Should_True_When_False()
        {
            // Arrange
            ISpecification <object> spec = new FalseSpecification <object>();

            spec = new NotSpecification <object>(spec);

            // Act
            var result = spec.IsSatisfiedBy(new object());

            // Assert
            result.Should().BeTrue();
        }
            public void CorrectData_ReturnExpectedResultObject(bool isNegatable, SpecificationResult expected)
            {
                var specification = !isNegatable
                    ? MockComplexSpecification.False()
                    : MockNegatableComplexSpecification.False();

                var sut = new NotSpecification <object>(specification);

                var overall = sut.IsSatisfiedBy(new object(), out var result);

                Assert.True(overall);
                Assert.Equal(expected, result, new SpecificationResultComparer());
            }
Ejemplo n.º 22
0
        public void IsSatisfiedBy_01()
        {
            // arrange:
            object candidate = new object();
            ISpecification <object> toNegate = MockRepository.GenerateMock <ISpecification <object> >();

            toNegate.Expect(s => s.IsSatisfiedBy(candidate)).Return(true);

            // act:
            NotSpecification <object> spec = new NotSpecification <object>(toNegate);
            bool satisfied = spec.IsSatisfiedBy(candidate);

            // assert:
            Assert.IsFalse(satisfied);
            toNegate.VerifyAllExpectations();
        }
                public When_Invoked()
                {
                    subject = new object();

                    option = new NotSpecification(
                        new Specification(
                            s => {
                                option1Subject = s;
                                option1Called = true;
                                return false;
                            }
                        )
                    );

                    option.IsSatisfiedBy(subject);
                }
Ejemplo n.º 24
0
        public void NotSpecification_Test()
        {
            var notSpec = new NotSpecification <TestObjects.Member>(spec);

            Assert.That(notSpec.IsSatisfiedBy(member));
        }
Ejemplo n.º 25
0
        public void Can_Be_Constructed_With_Expression()
        {
            var spec = new NotSpecification <object>(obj => true);

            Assert.That(spec.IsSatisfiedBy(new object()), Is.False);
        }