|
| 1 | +using System.Collections.Generic; |
| 2 | +using System.Linq; |
| 3 | +using NTestDataBuilder.EquivalenceClasses; |
| 4 | +using Shouldly; |
| 5 | +using Xunit; |
| 6 | + |
| 7 | +namespace NTestDataBuilder.Tests.EquivalenceClasses |
| 8 | +{ |
| 9 | + public class IntegerEquivalenceClassesTests |
| 10 | + { |
| 11 | + public AnonymousValueFixture Any { get; private set; } |
| 12 | + |
| 13 | + public IntegerEquivalenceClassesTests() |
| 14 | + { |
| 15 | + Any = new AnonymousValueFixture(); |
| 16 | + } |
| 17 | + |
| 18 | + [Fact] |
| 19 | + public void WhenGettingAnyPositiveInteger_ThenReturnDifferentPositiveIntegersEveryTime() |
| 20 | + { |
| 21 | + var s1 = Any.PositiveInteger(); |
| 22 | + var s2 = Any.PositiveInteger(); |
| 23 | + |
| 24 | + s1.ShouldBeOfType<int>(); |
| 25 | + s2.ShouldBeOfType<int>(); |
| 26 | + s1.ShouldBeGreaterThan(0); |
| 27 | + s2.ShouldBeGreaterThan(0); |
| 28 | + s1.ShouldNotBe(s2); |
| 29 | + } |
| 30 | + |
| 31 | + [Fact] |
| 32 | + public void WhenGettingAnyNegativeInteger_ThenReturnDifferentNegativeIntegersEveryTime() |
| 33 | + { |
| 34 | + var s1 = Any.NegativeInteger(); |
| 35 | + var s2 = Any.NegativeInteger(); |
| 36 | + |
| 37 | + s1.ShouldBeOfType<int>(); |
| 38 | + s2.ShouldBeOfType<int>(); |
| 39 | + s1.ShouldBeLessThan(0); |
| 40 | + s2.ShouldBeLessThan(0); |
| 41 | + s1.ShouldNotBe(s2); |
| 42 | + } |
| 43 | + |
| 44 | + [Fact] |
| 45 | + public void WhenGettingAnyIntegerExceptASetOfIntegers_ThenReturnDifferentIntegersExceptTheGivenIntegersEveryTime() |
| 46 | + { |
| 47 | + var generated = new List<int>(); |
| 48 | + |
| 49 | + for (var i = 0; i < 1000; i++) |
| 50 | + { |
| 51 | + var integer = Any.IntegerExcept(1, 5, 200, 356, 4, 53); |
| 52 | + generated.Add(integer); |
| 53 | + } |
| 54 | + |
| 55 | + generated.ShouldAllBe(i => i != 1 |
| 56 | + && i != 5 |
| 57 | + && i != 200 |
| 58 | + && i != 356 |
| 59 | + && i != 4 |
| 60 | + && i != 53); |
| 61 | + generated.Distinct().Count() |
| 62 | + .ShouldBe(generated.Count); |
| 63 | + } |
| 64 | + } |
| 65 | +} |
0 commit comments