public NebulaCheck.IGen <Test> ItProducesValuesLikeInt32() => from min in Gen.Int16() from max in Gen.Int16().GreaterThanEqual(min) from origin in Gen.Int16().Between(min, max) from bias in DomainGen.Bias() from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => {
public NebulaCheck.IGen <Test> LessThanDefersToUnderlyingMethod() => from maxExclusive in Gen.Int16().GreaterThan(short.MinValue) select Property.ForThese(() => { var mockGen = SetupMock(); mockGen.Object.LessThan(maxExclusive); mockGen.Verify(gen => gen.LessThanEqual((short)(maxExclusive - 1)), Times.Once); });
public NebulaCheck.IGen <Test> ItErrorsWhenMaximumIsLessThanOrigin() => from max in Gen.Int16().LessThan(short.MaxValue) from origin in Gen.Int16().GreaterThan(max) from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => { var gen = GalaxyCheck.Gen.Int16().LessThanEqual(max).ShrinkTowards(origin); Action action = () => gen.SampleOne(seed: seed, size: size); action.Should() .Throw <GalaxyCheck.Exceptions.GenErrorException>() .WithMessage("Error while running generator Int16: 'origin' must be between 'min' and 'max'"); });
public NebulaCheck.IGen <Test> ItErrorsWhenMinimumIsGreaterThanMaximum() => from min in Gen.Int16().GreaterThan(short.MinValue) from max in Gen.Int16().LessThan(min) from seed in DomainGen.Seed() from size in DomainGen.Size() select Property.ForThese(() => { var gen = GalaxyCheck.Gen.Int16().GreaterThanEqual(min).LessThanEqual(max); Action action = () => gen.SampleOne(seed: seed, size: size); action.Should() .Throw <GalaxyCheck.Exceptions.GenErrorException>() .WithMessage("Error while running generator Int16: 'min' cannot be greater than 'max'"); });
public NebulaCheck.IGen <Test> BetweenDefersToUnderlyingMethods() => from min in Gen.Int16() from max in Gen.Int16().GreaterThanEqual(min) select Property.ForThese(() => { { var mockGen = SetupMock(); mockGen.Object.Between(min, max); mockGen.Verify(gen => gen.GreaterThanEqual(min), Times.Once); mockGen.Verify(gen => gen.LessThanEqual(max), Times.Once); } { var mockGen = SetupMock(); mockGen.Object.Between(max, min); mockGen.Verify(gen => gen.GreaterThanEqual(min), Times.Once); mockGen.Verify(gen => gen.LessThanEqual(max), Times.Once); } });