public void InvokeCompositeLessThanOrEqual_ReturnLessThanOrEqualSpecification() { var comparer = new FakeIntComparer(); var expected = new LessThanOrEqualSpecification <int>(0, comparer); var sut = new MockCompositeSpecification <int>().LessThanOrEqual(0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeCompositeGreaterThan_ReturnGreaterThanSpecification() { var comparer = new FakeIntComparer(); var expected = new GreaterThanSpecification <int>(0, comparer); var sut = new MockCompositeSpecification <int>().GreaterThan(0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeLessThan_ReturnLessThanSpecification() { var comparer = new FakeIntComparer(); var expected = new LessThanSpecification <int>(0, comparer); var sut = Specification.LessThan(0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeCompositeExclusiveBetween_ReturnExclusiveBetweenSpecification() { var comparer = new FakeIntComparer(); var expected = new ExclusiveBetweenSpecification <int>(0, 0, comparer); var sut = new MockCompositeSpecification <int>().ExclusiveBetween(0, 0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeInclusiveBetween_ReturnInclusiveBetweenSpecification() { var comparer = new FakeIntComparer(); var expected = new InclusiveBetweenSpecification <int>(0, 0, comparer); var sut = Specification.InclusiveBetween(0, 0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeContains_ReturnContainsSpecification() { var comparer = new FakeIntComparer(); var expected = new ContainsSpecification <FakeType, int>(0, comparer, true); var sut = Specification.Contains <FakeType, int>(0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeEqual_ReturnEqualSpecification() { var comparer = new FakeIntComparer(); var expected = new EqualSpecification <int>(0, comparer); var sut = Specification.Equal(0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeCompositeNotEqual_ReturnNotSpecification() { var comparer = new FakeIntComparer(); var expected = new NotSpecification <int>( new EqualSpecification <int>(0, comparer)); var sut = new MockCompositeSpecification <int>().NotEqual(0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeNotGreaterThanOrEqual_ReturnNotSpecification() { var comparer = new FakeIntComparer(); var expected = new NotSpecification <int>( new GreaterThanOrEqualSpecification <int>(0, comparer)); var sut = Specification.NotGreaterThanOrEqual(0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeCompositeNotContains_ReturnNotSpecification() { var comparer = new FakeIntComparer(); var expected = new NotSpecification <FakeType>( new ContainsSpecification <FakeType, int>(0, comparer, true)); var sut = new MockCompositeSpecification <FakeType>().NotContains(0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeCompositeLessThanOrEqualProperty_ReturnPropertySpecification() { var comparer = new FakeIntComparer(); var expected = new PropertySpecification <FakeType, int>( ft => ft.First, new LessThanOrEqualSpecification <int>(0, comparer)); var sut = new MockCompositeSpecification <FakeType>().LessThanOrEqual( ft => ft.First, 0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeContainsProperty_ReturnPropertySpecification() { var comparer = new FakeIntComparer(); var expected = new PropertySpecification <FakeType, IEnumerable <int> >( ft => ft.Fourth, new ContainsSpecification <IEnumerable <int>, int>(0, comparer, true)); var sut = Specification.Contains <FakeType, int>( ft => ft.Fourth, 0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeEqualProperty_ReturnPropertySpecification() { var comparer = new FakeIntComparer(); var expected = new PropertySpecification <FakeType, int>( ft => ft.First, new EqualSpecification <int>(0, comparer)); var sut = Specification.Equal <FakeType, int>( ft => ft.First, 0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeCompositeInclusiveBetweenProperty_ReturnPropertySpecification() { var comparer = new FakeIntComparer(); var expected = new PropertySpecification <FakeType, int>( ft => ft.First, new InclusiveBetweenSpecification <int>(0, 0, comparer)); var sut = new MockCompositeSpecification <FakeType>().InclusiveBetween( ft => ft.First, 0, 0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeNotExclusiveBetweenProperty_ReturnPropertySpecification() { var comparer = new FakeIntComparer(); var expected = new PropertySpecification <FakeType, int>( ft => ft.First, new NotSpecification <int>( new ExclusiveBetweenSpecification <int>(0, 0, comparer))); var sut = Specification.NotExclusiveBetween <FakeType, int>( ft => ft.First, 0, 0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public void InvokeCompositeNotGreaterThanProperty_ReturnPropertySpecification() { var comparer = new FakeIntComparer(); var expected = new PropertySpecification <FakeType, int>( ft => ft.First, new NotSpecification <int>( new GreaterThanSpecification <int>(0, comparer))); var sut = new MockCompositeSpecification <FakeType>().NotGreaterThan( ft => ft.First, 0, comparer); Assert.Equal(expected, sut, new SpecificationComparer()); }
public EqualData() { var comparer = new FakeTypeComparer(); var intComparer = new FakeIntComparer(); var obj1 = new object(); var obj2 = obj1; EquatableFakeType eq1 = new EquatableFakeType { First = 15 }, eq2 = new EquatableFakeType { First = 15 }; ComparableFakeType cmp1 = new ComparableFakeType { First = 15 }, cmp2 = new ComparableFakeType { First = 15 }; ComparableInterFakeType cmpInter1 = new ComparableInterFakeType(), cmpInter2 = new ComparableInterFakeType(); FakeType ft1 = new FakeType { First = 15 }, ft2 = new FakeType { First = 15 }; AddValid(obj1, obj2, null) .Result("EqualSpecification<Object>") .NegationResult("NotEqualSpecification<Object>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <object>), "Object is equal to [System.Object]") .Candidate(obj1) .AddParameter("Expected", obj2)); AddValid("test", "test", null) .Result("EqualSpecification<String>") .NegationResult("NotEqualSpecification<String>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <string>), "Object is equal to [test]") .Candidate("test") .AddParameter("Expected", "test")); AddValid(1, 1, null) .Result("EqualSpecification<Int32>") .NegationResult("NotEqualSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <int>), "Object is equal to [1]") .Candidate(1) .AddParameter("Expected", 1)); AddValid(1, 1, intComparer) .Result("EqualSpecification<Int32>") .NegationResult("NotEqualSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <int>), "Object is equal to [1]") .Candidate(1) .AddParameter("Expected", 1)); AddValid(5.74, 5.74, null) .Result("EqualSpecification<Double>") .NegationResult("NotEqualSpecification<Double>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <double>), "Object is equal to [5.74]") .Candidate(5.74) .AddParameter("Expected", 5.74)); AddValid(false, false, null) .Result("EqualSpecification<Boolean>") .NegationResult("NotEqualSpecification<Boolean>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <bool>), "Object is equal to [False]") .Candidate(false) .AddParameter("Expected", false)); AddValid(eq1, eq2, null) .Result("EqualSpecification<EquatableFakeType>") .NegationResult("NotEqualSpecification<EquatableFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <EquatableFakeType>), "Object is equal to [Fake(15)]") .Candidate(eq1) .AddParameter("Expected", eq2)); AddValid(cmp1, cmp2, null) .Result("EqualSpecification<ComparableFakeType>") .NegationResult("NotEqualSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <ComparableFakeType>), "Object is equal to [Fake(15)]") .Candidate(cmp1) .AddParameter("Expected", cmp2)); AddValid(cmpInter1, cmpInter2, null) .Result("EqualSpecification<ComparableInterFakeType>") .NegationResult("NotEqualSpecification<ComparableInterFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <ComparableInterFakeType>), "Object is equal to [FluentSpecification.Tests.Mocks.ComparableInterFakeType]") .Candidate(cmpInter1) .AddParameter("Expected", cmpInter2)); AddValid(ft1, ft2, comparer) .Result("EqualSpecification<FakeType>") .NegationResult("NotEqualSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <FakeType>), "Object is equal to [Fake(15)]") .Candidate(ft1) .AddParameter("Expected", ft2)); AddValid(null, null, null) .Result("EqualSpecification<Object>") .NegationResult("NotEqualSpecification<Object>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <object>), "Object is equal to [null]") .Candidate(null) .AddParameter("Expected", null)); AddValid("null", null, null) .Result("EqualSpecification<String>") .NegationResult("NotEqualSpecification<String>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <string>), "Object is equal to [null]") .Candidate(null) .AddParameter("Expected", null)); AddValid(new EquatableFakeType { Second = "null" }, null, null) .Result("EqualSpecification<EquatableFakeType>") .NegationResult("NotEqualSpecification<EquatableFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <EquatableFakeType>), "Object is equal to [null]") .Candidate(null) .AddParameter("Expected", null)); AddValid(new ComparableFakeType { Second = "null" }, null, null) .Result("EqualSpecification<ComparableFakeType>") .NegationResult("NotEqualSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <ComparableFakeType>), "Object is equal to [null]") .Candidate(null) .AddParameter("Expected", null)); AddValid(new FakeType { Second = "null" }, null, comparer) .Result("EqualSpecification<FakeType>") .NegationResult("NotEqualSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <FakeType>), "Object is equal to [null]") .Candidate(null) .AddParameter("Expected", null)); var obj3 = new object(); var neq = new EquatableFakeType { First = 11 }; var notCmp = new ComparableFakeType { First = 11 }; var notCmpInter = new ComparableInterFakeType { Third = true }; FakeType f1 = new FakeType(), f2 = new FakeType(); AddInvalid(obj1, obj3, null) .NegationResult("NotEqualSpecification<Object>") .Result("EqualSpecification<Object>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <object>), "Object is not equal to [System.Object]") .Candidate(obj1) .AddParameter("Expected", obj3)); AddInvalid("test", "another test", null) .NegationResult("NotEqualSpecification<String>") .Result("EqualSpecification<String>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <string>), "Object is not equal to [another test]") .Candidate("test") .AddParameter("Expected", "another test")); AddInvalid("test", null, null) .NegationResult("NotEqualSpecification<String>") .Result("EqualSpecification<String>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <string>), "Object is not equal to [null]") .Candidate("test") .AddParameter("Expected", null)); AddInvalid("null", "test", null) .NegationResult("NotEqualSpecification<String>") .Result("EqualSpecification<String>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <string>), "Object is not equal to [test]") .Candidate(null) .AddParameter("Expected", "test")); AddInvalid(1, -1, null) .NegationResult("NotEqualSpecification<Int32>") .Result("EqualSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <int>), "Object is not equal to [-1]") .Candidate(1) .AddParameter("Expected", -1)); AddInvalid(1, -1, intComparer) .NegationResult("NotEqualSpecification<Int32>") .Result("EqualSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <int>), "Object is not equal to [-1]") .Candidate(1) .AddParameter("Expected", -1)); AddInvalid(5.74, 3.74, null) .NegationResult("NotEqualSpecification<Double>") .Result("EqualSpecification<Double>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <double>), "Object is not equal to [3.74]") .Candidate(5.74) .AddParameter("Expected", 3.74)); AddInvalid(false, true, null) .NegationResult("NotEqualSpecification<Boolean>") .Result("EqualSpecification<Boolean>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <bool>), "Object is not equal to [True]") .Candidate(false) .AddParameter("Expected", true)); AddInvalid(obj1, null, null) .NegationResult("NotEqualSpecification<Object>") .Result("EqualSpecification<Object>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <object>), "Object is not equal to [null]") .Candidate(obj1) .AddParameter("Expected", null)); AddInvalid(null, obj1, null) .NegationResult("NotEqualSpecification<Object>") .Result("EqualSpecification<Object>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <object>), "Object is not equal to [System.Object]") .Candidate(null) .AddParameter("Expected", obj1)); AddInvalid(eq1, neq, null) .NegationResult("NotEqualSpecification<EquatableFakeType>") .Result("EqualSpecification<EquatableFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <EquatableFakeType>), "Object is not equal to [Fake(11)]") .Candidate(eq1) .AddParameter("Expected", neq)); AddInvalid(eq1, null, null) .NegationResult("NotEqualSpecification<EquatableFakeType>") .Result("EqualSpecification<EquatableFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <EquatableFakeType>), "Object is not equal to [null]") .Candidate(eq1) .AddParameter("Expected", null)); AddInvalid(new EquatableFakeType { Second = "null" }, eq1, null) .NegationResult("NotEqualSpecification<EquatableFakeType>") .Result("EqualSpecification<EquatableFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <EquatableFakeType>), "Object is not equal to [Fake(15)]") .Candidate(null) .AddParameter("Expected", eq1)); AddInvalid(cmp1, notCmp, null) .NegationResult("NotEqualSpecification<ComparableFakeType>") .Result("EqualSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <ComparableFakeType>), "Object is not equal to [Fake(11)]") .Candidate(cmp1) .AddParameter("Expected", notCmp)); AddInvalid(cmp1, null, null) .NegationResult("NotEqualSpecification<ComparableFakeType>") .Result("EqualSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <ComparableFakeType>), "Object is not equal to [null]") .Candidate(cmp1) .AddParameter("Expected", null)); AddInvalid(new ComparableFakeType { Second = "null" }, cmp1, null) .NegationResult("NotEqualSpecification<ComparableFakeType>") .Result("EqualSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <ComparableFakeType>), "Object is not equal to [Fake(15)]") .Candidate(null) .AddParameter("Expected", cmp1)); AddInvalid(cmpInter1, notCmpInter, null) .NegationResult("NotEqualSpecification<ComparableInterFakeType>") .Result("EqualSpecification<ComparableInterFakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <ComparableInterFakeType>), "Object is not equal to [FluentSpecification.Tests.Mocks.ComparableInterFakeType]") .Candidate(cmpInter1) .AddParameter("Expected", notCmpInter)); AddInvalid(f1, f2, null) .NegationResult("NotEqualSpecification<FakeType>") .Result("EqualSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <FakeType>), "Object is not equal to [Fake(0)]") .Candidate(f1) .AddParameter("Expected", f2)); AddInvalid(f1, null, comparer) .NegationResult("NotEqualSpecification<FakeType>") .Result("EqualSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <FakeType>), "Object is not equal to [null]") .Candidate(f1) .AddParameter("Expected", null)); AddInvalid(new FakeType { Second = "null" }, f1, comparer) .NegationResult("NotEqualSpecification<FakeType>") .Result("EqualSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(EqualSpecification <FakeType>), "Object is not equal to [Fake(0)]") .Candidate(null) .AddParameter("Expected", f1)); }
public ExclusiveBetweenData() { var comparer = new FakeTypeComparer(); var intComparer = new FakeIntComparer(); ComparableFakeType cmp = new ComparableFakeType { First = 15 }, cmpFrom = new ComparableFakeType { First = 1 }, cmpTo = new ComparableFakeType { First = 30 }; FakeType cmpFakeType = new FakeType { First = 15 }, cmpFromFakeType = new FakeType { First = 1 }, cmpToFakeType = new FakeType { First = 30 }; AddValid(1, 0, 5, null) .Result("ExclusiveBetweenSpecification<Int32>") .NegationResult("NotExclusiveBetweenSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <int>), "Value is between [0] and [5]") .Candidate(1) .AddParameter("From", 0) .AddParameter("To", 5)); AddValid(-1, -5, 1, null) .Result("ExclusiveBetweenSpecification<Int32>") .NegationResult("NotExclusiveBetweenSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <int>), "Value is between [-5] and [1]") .Candidate(-1) .AddParameter("From", -5) .AddParameter("To", 1)); AddValid(-9, -24, -1, intComparer) .Result("ExclusiveBetweenSpecification<Int32>") .NegationResult("NotExclusiveBetweenSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <int>), "Value is between [-24] and [-1]") .Candidate(-9) .AddParameter("From", -24) .AddParameter("To", -1)); AddValid(5.74, 5.73, 5.75, null) .Result("ExclusiveBetweenSpecification<Double>") .NegationResult("NotExclusiveBetweenSpecification<Double>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <double>), "Value is between [5.73] and [5.75]") .Candidate(5.74) .AddParameter("From", 5.73) .AddParameter("To", 5.75)); AddValid(-2.5, -3.0, 0.0, null) .Result("ExclusiveBetweenSpecification<Double>") .NegationResult("NotExclusiveBetweenSpecification<Double>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <double>), "Value is between [-3] and [0]") .Candidate(-2.5) .AddParameter("From", -3.0) .AddParameter("To", 0.0)); AddValid(-5.75, -5.76, -5.74, null) .Result("ExclusiveBetweenSpecification<Double>") .NegationResult("NotExclusiveBetweenSpecification<Double>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <double>), "Value is between [-5.76] and [-5.74]") .Candidate(-5.75) .AddParameter("From", -5.76) .AddParameter("To", -5.74)); AddValid("123", "122", "124", null) .Result("ExclusiveBetweenSpecification<String>") .NegationResult("NotExclusiveBetweenSpecification<String>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <string>), "Value is between [122] and [124]") .Candidate("123") .AddParameter("From", "122") .AddParameter("To", "124")); AddValid("123", "12", "1234", null) .Result("ExclusiveBetweenSpecification<String>") .NegationResult("NotExclusiveBetweenSpecification<String>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <string>), "Value is between [12] and [1234]") .Candidate("123") .AddParameter("From", "12") .AddParameter("To", "1234")); AddValid("test", null, "test1", null) .Result("ExclusiveBetweenSpecification<String>") .NegationResult("NotExclusiveBetweenSpecification<String>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <string>), "Value is between [null] and [test1]") .Candidate("test") .AddParameter("From", null) .AddParameter("To", "test1")); AddValid(DateTime.Parse("2018-01-15"), DateTime.Parse("2017-05-16"), DateTime.Parse("2019-07-11"), null) .Result("ExclusiveBetweenSpecification<DateTime>") .NegationResult("NotExclusiveBetweenSpecification<DateTime>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <DateTime>), $"Value is between \\[{DateTimeRegexPattern}\\] and \\[{DateTimeRegexPattern}\\]") .Candidate(DateTime.Parse("2018-01-15")) .AddParameter("From", DateTime.Parse("2017-05-16")) .AddParameter("To", DateTime.Parse("2019-07-11"))); AddValid(DateTime.Parse("2019-07-05"), DateTime.Parse("2019-07-01"), DateTime.Parse("2019-07-11"), null) .Result("ExclusiveBetweenSpecification<DateTime>") .NegationResult("NotExclusiveBetweenSpecification<DateTime>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <DateTime>), $"Value is between \\[{DateTimeRegexPattern}\\] and \\[{DateTimeRegexPattern}\\]") .Candidate(DateTime.Parse("2019-07-05")) .AddParameter("From", DateTime.Parse("2019-07-01")) .AddParameter("To", DateTime.Parse("2019-07-11"))); AddValid(cmp, cmpFrom, cmpTo, null) .Result("ExclusiveBetweenSpecification<ComparableFakeType>") .NegationResult("NotExclusiveBetweenSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <ComparableFakeType>), "Value is between [Fake(1)] and [Fake(30)]") .Candidate(cmp) .AddParameter("From", cmpFrom) .AddParameter("To", cmpTo)); AddValid(cmp, null, cmpTo, null) .Result("ExclusiveBetweenSpecification<ComparableFakeType>") .NegationResult("NotExclusiveBetweenSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <ComparableFakeType>), "Value is between [null] and [Fake(30)]") .Candidate(cmp) .AddParameter("From", null) .AddParameter("To", cmpTo)); AddValid(cmpFakeType, cmpFromFakeType, cmpToFakeType, comparer) .Result("ExclusiveBetweenSpecification<FakeType>") .NegationResult("NotExclusiveBetweenSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <FakeType>), "Value is between [Fake(1)] and [Fake(30)]") .Candidate(cmpFakeType) .AddParameter("From", cmpFromFakeType) .AddParameter("To", cmpToFakeType)); AddValid(cmpFakeType, null, cmpToFakeType, comparer) .Result("ExclusiveBetweenSpecification<FakeType>") .NegationResult("NotExclusiveBetweenSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <FakeType>), "Value is between [null] and [Fake(30)]") .Candidate(cmpFakeType) .AddParameter("From", null) .AddParameter("To", cmpToFakeType)); ComparableFakeType notCmp1 = new ComparableFakeType { First = 10 }, notCmp2 = new ComparableFakeType { First = 15 }, notCmp3 = new ComparableFakeType { First = 1 }, notCmp4 = new ComparableFakeType { First = 3 }, notCmp5 = new ComparableFakeType { First = 23 }, notCmp6 = new ComparableFakeType { First = 30 }; ComparableInterFakeType cmpInter1 = new ComparableInterFakeType(), cmpInter2 = new ComparableInterFakeType(), cmpInter3 = new ComparableInterFakeType { Third = true }; FakeType notCmpFakeType1 = new FakeType { First = 10 }, notCmpFakeType2 = new FakeType { First = 15 }, notCmpFakeType3 = new FakeType { First = 1 }, notCmpFakeType4 = new FakeType { First = 3 }, notCmpFakeType5 = new FakeType { First = 23 }, notCmpFakeType6 = new FakeType { First = 30 }; AddInvalid(2, 2, 3, null) .NegationResult("NotExclusiveBetweenSpecification<Int32>") .Result("ExclusiveBetweenSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <int>), "Value is not between [2] and [3]") .Candidate(2) .AddParameter("From", 2) .AddParameter("To", 3)); AddInvalid(-2, -3, -2, null) .NegationResult("NotExclusiveBetweenSpecification<Int32>") .Result("ExclusiveBetweenSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <int>), "Value is not between [-3] and [-2]") .Candidate(-2) .AddParameter("From", -3) .AddParameter("To", -2)); AddInvalid(1, -3, -1, null) .NegationResult("NotExclusiveBetweenSpecification<Int32>") .Result("ExclusiveBetweenSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <int>), "Value is not between [-3] and [-1]") .Candidate(1) .AddParameter("From", -3) .AddParameter("To", -1)); AddInvalid(5, 1, 3, null) .NegationResult("NotExclusiveBetweenSpecification<Int32>") .Result("ExclusiveBetweenSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <int>), "Value is not between [1] and [3]") .Candidate(5) .AddParameter("From", 1) .AddParameter("To", 3)); AddInvalid(-1, -10, -5, intComparer) .NegationResult("NotExclusiveBetweenSpecification<Int32>") .Result("ExclusiveBetweenSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <int>), "Value is not between [-10] and [-5]") .Candidate(-1) .AddParameter("From", -10) .AddParameter("To", -5)); AddInvalid(3.5, 3.5, 3.5, null) .NegationResult("NotExclusiveBetweenSpecification<Double>") .Result("ExclusiveBetweenSpecification<Double>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <double>), "Value is not between [3.5] and [3.5]") .Candidate(3.5) .AddParameter("From", 3.5) .AddParameter("To", 3.5)); AddInvalid(-3.5, -3.5, -3.5, null) .NegationResult("NotExclusiveBetweenSpecification<Double>") .Result("ExclusiveBetweenSpecification<Double>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <double>), "Value is not between [-3.5] and [-3.5]") .Candidate(-3.5) .AddParameter("From", -3.5) .AddParameter("To", -3.5)); AddInvalid(5.74, 2.74, 3.74, null) .NegationResult("NotExclusiveBetweenSpecification<Double>") .Result("ExclusiveBetweenSpecification<Double>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <double>), "Value is not between [2.74] and [3.74]") .Candidate(5.74) .AddParameter("From", 2.74) .AddParameter("To", 3.74)); AddInvalid(-3.74, -7.74, -5.74, null) .NegationResult("NotExclusiveBetweenSpecification<Double>") .Result("ExclusiveBetweenSpecification<Double>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <double>), "Value is not between [-7.74] and [-5.74]") .Candidate(-3.74) .AddParameter("From", -7.74) .AddParameter("To", -5.74)); AddInvalid(5.74, -3.74, 5.73, null) .NegationResult("NotExclusiveBetweenSpecification<Double>") .Result("ExclusiveBetweenSpecification<Double>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <double>), "Value is not between [-3.74] and [5.73]") .Candidate(5.74) .AddParameter("From", -3.74) .AddParameter("To", 5.73)); AddInvalid(false, false, true, null) .NegationResult("NotExclusiveBetweenSpecification<Boolean>") .Result("ExclusiveBetweenSpecification<Boolean>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <bool>), "Value is not between [False] and [True]") .Candidate(false) .AddParameter("From", false) .AddParameter("To", true)); AddInvalid("123", "121", "122", null) .NegationResult("NotExclusiveBetweenSpecification<String>") .Result("ExclusiveBetweenSpecification<String>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <string>), "Value is not between [121] and [122]") .Candidate("123") .AddParameter("From", "121") .AddParameter("To", "122")); AddInvalid("1234", "122", "1233", null) .NegationResult("NotExclusiveBetweenSpecification<String>") .Result("ExclusiveBetweenSpecification<String>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <string>), "Value is not between [122] and [1233]") .Candidate("1234") .AddParameter("From", "122") .AddParameter("To", "1233")); AddInvalid("123", "123", "124", null) .NegationResult("NotExclusiveBetweenSpecification<String>") .Result("ExclusiveBetweenSpecification<String>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <string>), "Value is not between [123] and [124]") .Candidate("123") .AddParameter("From", "123") .AddParameter("To", "124")); AddInvalid("null", "test", "test1", null) .NegationResult("NotExclusiveBetweenSpecification<String>") .Result("ExclusiveBetweenSpecification<String>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <string>), "Value is not between [test] and [test1]") .Candidate(null) .AddParameter("From", "test") .AddParameter("To", "test1")); AddInvalid("null", null, "test", null) .NegationResult("NotExclusiveBetweenSpecification<String>") .Result("ExclusiveBetweenSpecification<String>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <string>), "Value is not between [null] and [test]") .Candidate(null) .AddParameter("From", null) .AddParameter("To", "test")); AddInvalid("null", null, null, null) .NegationResult("NotExclusiveBetweenSpecification<String>") .Result("ExclusiveBetweenSpecification<String>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <string>), "Value is not between [null] and [null]") .Candidate(null) .AddParameter("From", null) .AddParameter("To", null)); AddInvalid(DateTime.Parse("2019-11-15"), DateTime.Parse("2019-07-11"), DateTime.Parse("2019-11-15"), null) .NegationResult("NotExclusiveBetweenSpecification<DateTime>") .Result("ExclusiveBetweenSpecification<DateTime>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <DateTime>), $"Value is not between \\[{DateTimeRegexPattern}\\] and \\[{DateTimeRegexPattern}\\]") .Candidate(DateTime.Parse("2019-11-15")) .AddParameter("From", DateTime.Parse("2019-07-11")) .AddParameter("To", DateTime.Parse("2019-11-15"))); AddInvalid(DateTime.Parse("2019-11-15"), DateTime.Parse("2019-12-11"), DateTime.Parse("2019-12-15"), null) .NegationResult("NotExclusiveBetweenSpecification<DateTime>") .Result("ExclusiveBetweenSpecification<DateTime>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <DateTime>), $"Value is not between \\[{DateTimeRegexPattern}\\] and \\[{DateTimeRegexPattern}\\]") .Candidate(DateTime.Parse("2019-11-15")) .AddParameter("From", DateTime.Parse("2019-12-11")) .AddParameter("To", DateTime.Parse("2019-12-15"))); AddInvalid(cmp, notCmp1, notCmp2, null) .NegationResult("NotExclusiveBetweenSpecification<ComparableFakeType>") .Result("ExclusiveBetweenSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <ComparableFakeType>), "Value is not between [Fake(10)] and [Fake(15)]") .Candidate(cmp) .AddParameter("From", notCmp1) .AddParameter("To", notCmp2)); AddInvalid(cmp, notCmp3, notCmp4, null) .NegationResult("NotExclusiveBetweenSpecification<ComparableFakeType>") .Result("ExclusiveBetweenSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <ComparableFakeType>), "Value is not between [Fake(1)] and [Fake(3)]") .Candidate(cmp) .AddParameter("From", notCmp3) .AddParameter("To", notCmp4)); AddInvalid(cmp, notCmp5, notCmp6, null) .NegationResult("NotExclusiveBetweenSpecification<ComparableFakeType>") .Result("ExclusiveBetweenSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <ComparableFakeType>), "Value is not between [Fake(23)] and [Fake(30)]") .Candidate(cmp) .AddParameter("From", notCmp5) .AddParameter("To", notCmp6)); AddInvalid(cmpInter1, cmpInter2, cmpInter3, null) .NegationResult("NotExclusiveBetweenSpecification<ComparableInterFakeType>") .Result("ExclusiveBetweenSpecification<ComparableInterFakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <ComparableInterFakeType>), "Value is not between [FluentSpecification.Tests.Mocks.ComparableInterFakeType] and [FluentSpecification.Tests.Mocks.ComparableInterFakeType]") .Candidate(cmpInter1) .AddParameter("From", cmpInter2) .AddParameter("To", cmpInter3)); AddInvalid(new ComparableFakeType { Second = "null" }, notCmp1, notCmp2, null) .NegationResult("NotExclusiveBetweenSpecification<ComparableFakeType>") .Result("ExclusiveBetweenSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <ComparableFakeType>), "Value is not between [Fake(10)] and [Fake(15)]") .Candidate(null) .AddParameter("From", notCmp1) .AddParameter("To", notCmp2)); AddInvalid(new ComparableFakeType { Second = "null" }, null, notCmp2, null) .NegationResult("NotExclusiveBetweenSpecification<ComparableFakeType>") .Result("ExclusiveBetweenSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <ComparableFakeType>), "Value is not between [null] and [Fake(15)]") .Candidate(null) .AddParameter("From", null) .AddParameter("To", notCmp2)); AddInvalid(new ComparableFakeType { Second = "null" }, null, null, null) .NegationResult("NotExclusiveBetweenSpecification<ComparableFakeType>") .Result("ExclusiveBetweenSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <ComparableFakeType>), "Value is not between [null] and [null]") .Candidate(null) .AddParameter("From", null) .AddParameter("To", null)); AddInvalid(cmpFakeType, notCmpFakeType1, notCmpFakeType2, comparer) .NegationResult("NotExclusiveBetweenSpecification<FakeType>") .Result("ExclusiveBetweenSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <FakeType>), "Value is not between [Fake(10)] and [Fake(15)]") .Candidate(cmpFakeType) .AddParameter("From", notCmpFakeType1) .AddParameter("To", notCmpFakeType2)); AddInvalid(cmpFakeType, notCmpFakeType3, notCmpFakeType4, comparer) .NegationResult("NotExclusiveBetweenSpecification<FakeType>") .Result("ExclusiveBetweenSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <FakeType>), "Value is not between [Fake(1)] and [Fake(3)]") .Candidate(cmpFakeType) .AddParameter("From", notCmpFakeType3) .AddParameter("To", notCmpFakeType4)); AddInvalid(cmpFakeType, notCmpFakeType5, notCmpFakeType6, comparer) .NegationResult("NotExclusiveBetweenSpecification<FakeType>") .Result("ExclusiveBetweenSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <FakeType>), "Value is not between [Fake(23)] and [Fake(30)]") .Candidate(cmpFakeType) .AddParameter("From", notCmpFakeType5) .AddParameter("To", notCmpFakeType6)); AddInvalid(new FakeType { Second = "null" }, notCmpFakeType1, notCmpFakeType2, comparer) .NegationResult("NotExclusiveBetweenSpecification<FakeType>") .Result("ExclusiveBetweenSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <FakeType>), "Value is not between [Fake(10)] and [Fake(15)]") .Candidate(null) .AddParameter("From", notCmpFakeType1) .AddParameter("To", notCmpFakeType2)); AddInvalid(new FakeType { Second = "null" }, null, notCmpFakeType2, comparer) .NegationResult("NotExclusiveBetweenSpecification<FakeType>") .Result("ExclusiveBetweenSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <FakeType>), "Value is not between [null] and [Fake(15)]") .Candidate(null) .AddParameter("From", null) .AddParameter("To", notCmpFakeType2)); AddInvalid(new FakeType { Second = "null" }, null, null, comparer) .NegationResult("NotExclusiveBetweenSpecification<FakeType>") .Result("ExclusiveBetweenSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(ExclusiveBetweenSpecification <FakeType>), "Value is not between [null] and [null]") .Candidate(null) .AddParameter("From", null) .AddParameter("To", null)); }
public LessThanData() { var comparer = new FakeTypeComparer(); var intComparer = new FakeIntComparer(); ComparableFakeType cmp = new ComparableFakeType { First = 116 }, cmp2 = new ComparableFakeType { First = 154 }; ComparableInterFakeType cmpInter1 = new ComparableInterFakeType(), cmpInter2 = new ComparableInterFakeType(), cmpInter3 = new ComparableInterFakeType { Third = true }; FakeType cmpFakeType = new FakeType { First = 116 }, cmpFakeType2 = new FakeType { First = 154 }; AddValid(1, 5, null) .Result("LessThanSpecification<Int32>") .NegationResult("NotLessThanSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <int>), "Object is lower than [5]") .Candidate(1) .AddParameter("LessThan", 5)); AddValid(-1, 1, null) .Result("LessThanSpecification<Int32>") .NegationResult("NotLessThanSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <int>), "Object is lower than [1]") .Candidate(-1) .AddParameter("LessThan", 1)); AddValid(-9, -1, intComparer) .Result("LessThanSpecification<Int32>") .NegationResult("NotLessThanSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <int>), "Object is lower than [-1]") .Candidate(-9) .AddParameter("LessThan", -1)); AddValid(5.74, 5.75, null) .Result("LessThanSpecification<Double>") .NegationResult("NotLessThanSpecification<Double>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <double>), "Object is lower than [5.75]") .Candidate(5.74) .AddParameter("LessThan", 5.75)); AddValid(-2.5, 0.0, null) .Result("LessThanSpecification<Double>") .NegationResult("NotLessThanSpecification<Double>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <double>), "Object is lower than [0]") .Candidate(-2.5) .AddParameter("LessThan", 0.0)); AddValid(-5.75, -5.74, null) .Result("LessThanSpecification<Double>") .NegationResult("NotLessThanSpecification<Double>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <double>), "Object is lower than [-5.74]") .Candidate(-5.75) .AddParameter("LessThan", -5.74)); AddValid(false, true, null) .Result("LessThanSpecification<Boolean>") .NegationResult("NotLessThanSpecification<Boolean>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <bool>), "Object is lower than [True]") .Candidate(false) .AddParameter("LessThan", true)); AddValid("123", "124", null) .Result("LessThanSpecification<String>") .NegationResult("NotLessThanSpecification<String>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <string>), "Object is lower than [124]") .Candidate("123") .AddParameter("LessThan", "124")); AddValid("123", "1234", null) .Result("LessThanSpecification<String>") .NegationResult("NotLessThanSpecification<String>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <string>), "Object is lower than [1234]") .Candidate("123") .AddParameter("LessThan", "1234")); AddValid("null", "test", null) .Result("LessThanSpecification<String>") .NegationResult("NotLessThanSpecification<String>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <string>), "Object is lower than [test]") .Candidate(null) .AddParameter("LessThan", "test")); AddValid(DateTime.Parse("2018-01-15"), DateTime.Parse("2019-07-11"), null) .Result("LessThanSpecification<DateTime>") .NegationResult("NotLessThanSpecification<DateTime>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <DateTime>), $"Object is lower than \\[{DateTimeRegexPattern}\\]") .Candidate(DateTime.Parse("2018-01-15")) .AddParameter("LessThan", DateTime.Parse("2019-07-11"))); AddValid(DateTime.Parse("2019-07-01"), DateTime.Parse("2019-07-11"), null) .Result("LessThanSpecification<DateTime>") .NegationResult("NotLessThanSpecification<DateTime>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <DateTime>), $"Object is lower than \\[{DateTimeRegexPattern}\\]") .Candidate(DateTime.Parse("2019-07-01")) .AddParameter("LessThan", DateTime.Parse("2019-07-11"))); AddValid(cmp, cmp2, null) .Result("LessThanSpecification<ComparableFakeType>") .NegationResult("NotLessThanSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <ComparableFakeType>), "Object is lower than [Fake(154)]") .Candidate(cmp) .AddParameter("LessThan", cmp2)); AddValid(new ComparableFakeType { Second = "null" }, new ComparableFakeType(), null) .Result("LessThanSpecification<ComparableFakeType>") .NegationResult("NotLessThanSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <ComparableFakeType>), "Object is lower than [Fake(0)]") .Candidate(null) .AddParameter("LessThan", new ComparableFakeType())); AddValid(cmpInter1, cmpInter3, null) .Result("LessThanSpecification<ComparableInterFakeType>") .NegationResult("NotLessThanSpecification<ComparableInterFakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <ComparableInterFakeType>), "Object is lower than [FluentSpecification.Tests.Mocks.ComparableInterFakeType]") .Candidate(cmpInter1) .AddParameter("LessThan", cmpInter3)); AddValid(cmpFakeType, cmpFakeType2, comparer) .Result("LessThanSpecification<FakeType>") .NegationResult("NotLessThanSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <FakeType>), "Object is lower than [Fake(154)]") .Candidate(cmpFakeType) .AddParameter("LessThan", cmpFakeType2)); AddValid(new FakeType { Second = "null" }, new FakeType(), comparer) .Result("LessThanSpecification<FakeType>") .NegationResult("NotLessThanSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <FakeType>), "Object is lower than [Fake(0)]") .Candidate(null) .AddParameter("LessThan", new FakeType())); ComparableFakeType notCmp1 = new ComparableFakeType { First = 11 }, notCmp2 = new ComparableFakeType { First = 10 }, notCmp3 = new ComparableFakeType { First = 10 }; FakeType notCmpFakeType1 = new FakeType { First = 11 }, notCmpFakeType2 = new FakeType { First = 10 }, notCmpFakeType3 = new FakeType { First = 10 }; AddInvalid(2, 2, null) .NegationResult("NotLessThanSpecification<Int32>") .Result("LessThanSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <int>), "Object is greater than or equal to [2]") .Candidate(2) .AddParameter("LessThan", 2)); AddInvalid(-2, -2, null) .NegationResult("NotLessThanSpecification<Int32>") .Result("LessThanSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <int>), "Object is greater than or equal to [-2]") .Candidate(-2) .AddParameter("LessThan", -2)); AddInvalid(1, -1, null) .NegationResult("NotLessThanSpecification<Int32>") .Result("LessThanSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <int>), "Object is greater than or equal to [-1]") .Candidate(1) .AddParameter("LessThan", -1)); AddInvalid(5, 3, null) .NegationResult("NotLessThanSpecification<Int32>") .Result("LessThanSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <int>), "Object is greater than or equal to [3]") .Candidate(5) .AddParameter("LessThan", 3)); AddInvalid(-1, -10, intComparer) .NegationResult("NotLessThanSpecification<Int32>") .Result("LessThanSpecification<Int32>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <int>), "Object is greater than or equal to [-10]") .Candidate(-1) .AddParameter("LessThan", -10)); AddInvalid(3.5, 3.5, null) .NegationResult("NotLessThanSpecification<Double>") .Result("LessThanSpecification<Double>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <double>), "Object is greater than or equal to [3.5]") .Candidate(3.5) .AddParameter("LessThan", 3.5)); AddInvalid(-3.5, -3.5, null) .NegationResult("NotLessThanSpecification<Double>") .Result("LessThanSpecification<Double>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <double>), "Object is greater than or equal to [-3.5]") .Candidate(-3.5) .AddParameter("LessThan", -3.5)); AddInvalid(5.74, 3.74, null) .NegationResult("NotLessThanSpecification<Double>") .Result("LessThanSpecification<Double>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <double>), "Object is greater than or equal to [3.74]") .Candidate(5.74) .AddParameter("LessThan", 3.74)); AddInvalid(-3.74, -5.74, null) .NegationResult("NotLessThanSpecification<Double>") .Result("LessThanSpecification<Double>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <double>), "Object is greater than or equal to [-5.74]") .Candidate(-3.74) .AddParameter("LessThan", -5.74)); AddInvalid(5.74, -3.74, null) .NegationResult("NotLessThanSpecification<Double>") .Result("LessThanSpecification<Double>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <double>), "Object is greater than or equal to [-3.74]") .Candidate(5.74) .AddParameter("LessThan", -3.74)); AddInvalid(true, false, null) .NegationResult("NotLessThanSpecification<Boolean>") .Result("LessThanSpecification<Boolean>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <bool>), "Object is greater than or equal to [False]") .Candidate(true) .AddParameter("LessThan", false)); AddInvalid(false, false, null) .NegationResult("NotLessThanSpecification<Boolean>") .Result("LessThanSpecification<Boolean>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <bool>), "Object is greater than or equal to [False]") .Candidate(false) .AddParameter("LessThan", false)); AddInvalid("123", "122", null) .NegationResult("NotLessThanSpecification<String>") .Result("LessThanSpecification<String>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <string>), "Object is greater than or equal to [122]") .Candidate("123") .AddParameter("LessThan", "122")); AddInvalid("1234", "123", null) .NegationResult("NotLessThanSpecification<String>") .Result("LessThanSpecification<String>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <string>), "Object is greater than or equal to [123]") .Candidate("1234") .AddParameter("LessThan", "123")); AddInvalid("123", "123", null) .NegationResult("NotLessThanSpecification<String>") .Result("LessThanSpecification<String>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <string>), "Object is greater than or equal to [123]") .Candidate("123") .AddParameter("LessThan", "123")); AddInvalid("test1", null, null) .NegationResult("NotLessThanSpecification<String>") .Result("LessThanSpecification<String>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <string>), "Object is greater than or equal to [null]") .Candidate("test1") .AddParameter("LessThan", null)); AddInvalid("null", null, null) .NegationResult("NotLessThanSpecification<String>") .Result("LessThanSpecification<String>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <string>), "Object is greater than or equal to [null]") .Candidate(null) .AddParameter("LessThan", null)); AddInvalid(DateTime.Parse("2019-11-15"), DateTime.Parse("2019-07-11"), null) .NegationResult("NotLessThanSpecification<DateTime>") .Result("LessThanSpecification<DateTime>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <DateTime>), $"Object is greater than or equal to \\[{DateTimeRegexPattern}\\]") .Candidate(DateTime.Parse("2019-11-15")) .AddParameter("LessThan", DateTime.Parse("2019-07-11"))); AddInvalid(DateTime.Parse("2019-07-11"), DateTime.Parse("2019-07-11"), null) .NegationResult("NotLessThanSpecification<DateTime>") .Result("LessThanSpecification<DateTime>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <DateTime>), $"Object is greater than or equal to \\[{DateTimeRegexPattern}\\]") .Candidate(DateTime.Parse("2019-07-11")) .AddParameter("LessThan", DateTime.Parse("2019-07-11"))); AddInvalid(notCmp1, notCmp2, null) .NegationResult("NotLessThanSpecification<ComparableFakeType>") .Result("LessThanSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <ComparableFakeType>), "Object is greater than or equal to [Fake(10)]") .Candidate(notCmp1) .AddParameter("LessThan", notCmp2)); AddInvalid(notCmp2, notCmp3, null) .NegationResult("NotLessThanSpecification<ComparableFakeType>") .Result("LessThanSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <ComparableFakeType>), "Object is greater than or equal to [Fake(10)]") .Candidate(notCmp2) .AddParameter("LessThan", notCmp3)); AddInvalid(new ComparableFakeType { Second = "null" }, null, null) .NegationResult("NotLessThanSpecification<ComparableFakeType>") .Result("LessThanSpecification<ComparableFakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <ComparableFakeType>), "Object is greater than or equal to [null]") .Candidate(null) .AddParameter("LessThan", null)); AddInvalid(cmpInter1, cmpInter2, null) .NegationResult("NotLessThanSpecification<ComparableInterFakeType>") .Result("LessThanSpecification<ComparableInterFakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <ComparableInterFakeType>), "Object is greater than or equal to [FluentSpecification.Tests.Mocks.ComparableInterFakeType]") .Candidate(cmpInter1) .AddParameter("LessThan", cmpInter2)); AddInvalid(notCmpFakeType1, notCmpFakeType2, comparer) .NegationResult("NotLessThanSpecification<FakeType>") .Result("LessThanSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <FakeType>), "Object is greater than or equal to [Fake(10)]") .Candidate(notCmpFakeType1) .AddParameter("LessThan", notCmpFakeType2)); AddInvalid(notCmpFakeType2, notCmpFakeType3, comparer) .NegationResult("NotLessThanSpecification<FakeType>") .Result("LessThanSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <FakeType>), "Object is greater than or equal to [Fake(10)]") .Candidate(notCmpFakeType2) .AddParameter("LessThan", notCmpFakeType3)); AddInvalid(new FakeType { Second = "null" }, null, comparer) .NegationResult("NotLessThanSpecification<FakeType>") .Result("LessThanSpecification<FakeType>+Failed", c => c .FailedSpecification(typeof(LessThanSpecification <FakeType>), "Object is greater than or equal to [null]") .Candidate(null) .AddParameter("LessThan", null)); }
public ContainsData() { var comparer = new FakeTypeComparer(); var intComparer = new FakeIntComparer(); int[] arr = { 1, 5, 200, 6, 100 }; var list = new List <string> { "First", "Second" }; var dict = new Dictionary <string, bool> { { "First", false }, { "Second", true } }; var cmp = new EquatableFakeType { First = 10 }; var notCmp = new EquatableFakeType { First = 100 }; EquatableFakeType[] cmpArr = { new EquatableFakeType { First = 11 }, new EquatableFakeType{ First = 10 } }; var ft = new FakeType { First = 1, Fourth = arr }; var empty = new FakeType { First = 1 }; FakeType[] ftArr = { ft, cmp, null }; var nullFt = new FakeType { Second = "null" }; AddValid(arr, 5, null) .Result("ContainsSpecification<Int32[],Int32>") .NegationResult("NotContainsSpecification<Int32[],Int32>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <int[], int>), "Collection contains [5]") .Candidate(arr) .AddParameter("Expected", 5)); AddValid(list, "Second", null) .Result("ContainsSpecification<List<String>,String>") .NegationResult("NotContainsSpecification<List<String>,String>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <List <string>, string>), "Collection contains [Second]") .Candidate(list) .AddParameter("Expected", "Second")); AddValid(dict, new KeyValuePair <string, bool>("First", false), null) .Result("ContainsSpecification<Dictionary<String,Boolean>,KeyValuePair<String,Boolean>>") .NegationResult( "NotContainsSpecification<Dictionary<String,Boolean>,KeyValuePair<String,Boolean>>+Failed", c => c .FailedSpecification( typeof(ContainsSpecification <Dictionary <string, bool>, KeyValuePair <string, bool> >), "Collection contains [[First, False]]") .Candidate(dict) .AddParameter("Expected", new KeyValuePair <string, bool>("First", false))); AddValid(cmpArr, cmp, null) .Result("ContainsSpecification<EquatableFakeType[],EquatableFakeType>") .NegationResult("NotContainsSpecification<EquatableFakeType[],EquatableFakeType>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <EquatableFakeType[], EquatableFakeType>), "Collection contains [Fake(10)]") .Candidate(cmpArr) .AddParameter("Expected", cmp)); AddValid(ft, 200, intComparer) .Result("ContainsSpecification<FakeType,Int32>") .NegationResult("NotContainsSpecification<FakeType,Int32>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <FakeType, int>), "Collection contains [200]") .Candidate(ft) .AddParameter("Expected", 200)); AddValid(ftArr, ft, null) .Result("ContainsSpecification<FakeType[],FakeType>") .NegationResult("NotContainsSpecification<FakeType[],FakeType>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <FakeType[], FakeType>), "Collection contains [Fake(1)]") .Candidate(ftArr) .AddParameter("Expected", ft)); AddValid(ftArr, empty, comparer) .Result("ContainsSpecification<FakeType[],FakeType>") .NegationResult("NotContainsSpecification<FakeType[],FakeType>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <FakeType[], FakeType>), "Collection contains [Fake(1)]") .Candidate(ftArr) .AddParameter("Expected", empty)); AddValid(ftArr, new FakeType { Second = "null" }, null) .Result("ContainsSpecification<FakeType[],FakeType>") .NegationResult("NotContainsSpecification<FakeType[],FakeType>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <FakeType[], FakeType>), "Collection contains [null]") .Candidate(ftArr) .AddParameter("Expected", null)); AddInvalid(arr, 16, null) .NegationResult("NotContainsSpecification<Int32[],Int32>") .Result("ContainsSpecification<Int32[],Int32>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <int[], int>), "Collection not contains [16]") .Candidate(arr) .AddParameter("Expected", 16)); AddInvalid(list, "Third", null) .NegationResult("NotContainsSpecification<List<String>,String>") .Result("ContainsSpecification<List<String>,String>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <List <string>, string>), "Collection not contains [Third]") .Candidate(list) .AddParameter("Expected", "Third")); AddInvalid(dict, new KeyValuePair <string, bool>("Third", false), null) .NegationResult("NotContainsSpecification<Dictionary<String,Boolean>,KeyValuePair<String,Boolean>>") .Result("ContainsSpecification<Dictionary<String,Boolean>,KeyValuePair<String,Boolean>>+Failed", c => c .FailedSpecification( typeof(ContainsSpecification <Dictionary <string, bool>, KeyValuePair <string, bool> >), "Collection not contains [[Third, False]]") .Candidate(dict) .AddParameter("Expected", new KeyValuePair <string, bool>("Third", false))); AddInvalid(ft, 16, intComparer) .NegationResult("NotContainsSpecification<FakeType,Int32>") .Result("ContainsSpecification<FakeType,Int32>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <FakeType, int>), "Collection not contains [16]") .Candidate(ft) .AddParameter("Expected", 16)); AddInvalid(cmpArr, notCmp, null) .NegationResult("NotContainsSpecification<EquatableFakeType[],EquatableFakeType>") .Result("ContainsSpecification<EquatableFakeType[],EquatableFakeType>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <EquatableFakeType[], EquatableFakeType>), "Collection not contains [Fake(100)]") .Candidate(cmpArr) .AddParameter("Expected", notCmp)); AddInvalid(ftArr, empty, null) .NegationResult("NotContainsSpecification<FakeType[],FakeType>") .Result("ContainsSpecification<FakeType[],FakeType>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <FakeType[], FakeType>), "Collection not contains [Fake(1)]") .Candidate(ftArr) .AddParameter("Expected", empty)); AddInvalid(nullFt, 1, null) .NegationResult("NotContainsSpecification<FakeType,Int32>") .Result("ContainsSpecification<FakeType,Int32>+Failed", c => c .FailedSpecification(typeof(ContainsSpecification <FakeType, int>), "Collection not contains [1]") .Candidate(null) .AddParameter("Expected", 1)); }