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()); }
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")); }
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()); }
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)); }
public void NotSpecification_Not_Test() { var notSpec = new NotSpecification <TestObjects.Member>(spec); member.City = "Moscow"; Assert.That(!notSpec.IsSatisfiedBy(member)); }
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 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); }
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(); }
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); }
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); }
public void NotSpecification_ShouldBeSatisfiedWhenUserNameIsEmpty() { var spec = new UsernameSpecification(); var not = new NotSpecification <User>(spec); var user1 = new User { username = "" }; not.IsSatisfiedBy(user1).Should().BeTrue(); }
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()); }
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); }
public void NotSpecification_Test() { var notSpec = new NotSpecification <TestObjects.Member>(spec); Assert.That(notSpec.IsSatisfiedBy(member)); }
public void Can_Be_Constructed_With_Expression() { var spec = new NotSpecification <object>(obj => true); Assert.That(spec.IsSatisfiedBy(new object()), Is.False); }