public void GetHashCode_retuns_same_value_for_equal_specifications() { var spec1 = new FalseSpecification <string>(); var spec2 = new FalseSpecification <string>(); Assert.AreEqual(spec1.GetHashCode(), spec2.GetHashCode()); }
public void IsSatisfied_Always_False() { var spec = new FalseSpecification <object>(); Assert.That(spec.IsSatisfiedBy(new object()), Is.False); Assert.That(spec.IsSatisfiedBy(null), Is.False); }
public void Should_work() { var spec = new FalseSpecification <string>(); var result = new SampleRepository().Find(spec); Assert.Empty(result); }
public void Equals_returns_true_when_both_sides_are_equals() { var spec1 = new FalseSpecification <string>(); var spec2 = new FalseSpecification <string>(); Assert.IsTrue(spec1.Equals(spec2)); }
public void Test_False() { FalseSpecification s = new FalseSpecification(); Assert.IsTrue(s.Test(false).Success); Assert.IsFalse(s.Test(true).Success); }
public void InvokeValidCandidate_ReturnFalse() { var sut = new FalseSpecification(); var result = sut.GetExpression().Compile().Invoke(true); Assert.False(result); }
public void ValidCandidate_ReturnFalse() { var sut = new FalseSpecification(); var result = sut.IsSatisfiedBy(true); Assert.False(result); }
public void InvalidCandidate_ReturnTrue() { var sut = new FalseSpecification(); var result = sut.IsSatisfiedBy(false); Assert.True(result); }
public void Multiple_IsSatisfied_Is_True_If_Single_Spec() { var single = new FalseSpecification <object>(); var spec = AndSpecification <object> .Multiple(single); Assert.That(spec.IsSatisfiedBy(new object()), Is.True); }
public void InvokeFalse_ReturnFalseSpecification() { var expected = new FalseSpecification(); var sut = Specification.False(); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeCompositeFalse_ReturnFalseSpecification() { var expected = new FalseSpecification(); var sut = new MockCompositeSpecification <bool>().False(); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void Equals_returns_false_when_both_sides_are_not_equals() { var spec = new FalseSpecification <string>(); Assert.IsFalse(spec.Equals(10)); Assert.IsFalse(spec.Equals(new AdHocSpecification <string>(x => true))); Assert.IsFalse(spec.Equals(new FalseSpecification <object>())); Assert.IsFalse(spec.Equals(Helpers.NullSpecification)); }
public void AndSpecification_ReturnsFalse_ForFalseSpec() { FalseSpecification falseSpec = new FalseSpecification(); TrueBoolSpecification trueBoolSpec = new TrueBoolSpecification(); AndSpecification <IBoolSpecification> andSpec = new AndSpecification <IBoolSpecification>(trueBoolSpec, trueBoolSpec); Assert.IsFalse(andSpec.IsSatisfiedBy(falseSpec), "AndSpecification returned true for false bool value."); }
public void Should_be_serializable() { var spec = new FalseSpecification <string>(); var deserializedSpec = Helpers.SerializeAndDeserialize(spec); Assert.That(deserializedSpec, Is.InstanceOf <FalseSpecification <string> >()); Assert.That(deserializedSpec.ToExpression().Compile().Invoke("any"), Is.False); }
public void Should_be_serializable() { var spec = new FalseSpecification <string>(); var deserializedSpec = Helpers.Helpers.SerializeAndDeserialize(spec); Assert.IsType <FalseSpecification <string> >(deserializedSpec); Assert.False(deserializedSpec.ToExpression().Compile().Invoke("any")); }
public void SutIsSpecification() { // Fixture setup // Exercise system var sut = new FalseSpecification <T>(); // Verify outcome Assert.IsAssignableFrom <ISpecification <T> >(sut); // Teardown }
public void InvalidCandidate_ReturnExpectedResultObject() { var expected = new SpecificationResult("FalseSpecification"); var sut = new FalseSpecification(); var overall = sut.IsSatisfiedBy(false, out var result); Assert.True(overall); Assert.Equal(expected, result, new SpecificationResultComparer()); }
public void NonGenericILinqSpecification_ReturnExpressionAsAbstractExpression() { var sut = new FalseSpecification(); var expected = sut.GetExpression().ToString(); var sutExpression = ((ILinqSpecification)sut).GetExpression(); var result = sutExpression.ToString(); Assert.Equal(expected, result); }
public void ValidCandidate_ReturnExpectedResultObject() { var expected = new SpecificationResult(false, "FalseSpecification+Failed", new FailedSpecification(typeof(FalseSpecification), true, "Value is True")); var sut = new FalseSpecification(); var overall = sut.IsSatisfiedBy(true, out var result); Assert.False(overall); Assert.Equal(expected, result, new SpecificationResultComparer()); }
public void Should_True_When_Always() { // Arrange var spec = new FalseSpecification <object>(); // Act var result = spec.IsSatisfiedBy(new object()); // Assert result.Should().BeFalse(); }
public void Should_Empty_When_False() { // Arrange var spec = new FalseSpecification <object>(); // Act var result = _objects.Where(spec); // Assert result.Should().BeEmpty(); }
public void IsSatisfiedByReturnsCorrectResult() { // Fixture setup var sut = new FalseSpecification <T>(); // Exercise system var dummyRequest = default(T); var result = sut.IsSatisfiedBy(dummyRequest); // Verify outcome Assert.False(result); // Teardown }
/// <summary> /// /// </summary> /// <returns></returns> public override Expression <Func <T, bool> > SatisfiedBy() { ISpecification <T> specification = new FalseSpecification <T>(); var properties = typeof(T).GetProperties().Where(p => p.CanWrite && p.PropertyType == typeof(string)); foreach (var property in properties) { specification = specification.Or(new PropertyContainsOrEqualSpecification <T>(property, Value)); } return(specification.SatisfiedBy()); }
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 ArgumentLess_Constructor() { var spec = new FalseSpecification <object>(); Assert.That(spec, Is.Not.Null); }
public When_Invoked() { option = new FalseSpecification(); result = option.IsSatisfiedBy(new object()); }