public NebulaCheck.IGen <Test> ItProducesValuesWithinTheGivenDates() => from seed in DomainGen.Seed() from size in DomainGen.Size() from fromDateTime in Gen.DateTime() from untilDateTime in Gen.DateTime().From(fromDateTime) select Property.ForThese(() => { var gen = GalaxyCheck.Gen.DateTime().From(fromDateTime).Until(untilDateTime); var sample = gen.SampleOneTraversal(seed: seed, size: size); sample.Should().OnlyContain(dt => fromDateTime <= dt && dt <= untilDateTime); });
public NebulaCheck.IGen <Test> ItErrorsWhenFromIsAfterUntil() => from seed in DomainGen.Seed() from size in DomainGen.Size() from fromDateTime in Gen.DateTime().From(DateTime.MinValue.AddMilliseconds(1)) from untilDateTime in Gen.DateTime().Until(fromDateTime.AddMilliseconds(-1)) select Property.ForThese(() => { var gen = GalaxyCheck.Gen.DateTime().From(fromDateTime).Until(untilDateTime); Action action = () => gen.SampleOne(seed: seed, size: size); action.Should() .Throw <GalaxyCheck.Exceptions.GenErrorException>() .WithMessage("Error while running generator DateTimeGen: 'from' datetime cannot be after 'until' datetime"); });
public NebulaCheck.IGen <Test> BetweenDefersToUnderlyingMethods() => from fromDate in Gen.DateTime() from untilDate in Gen.DateTime().From(fromDate) select Property.ForThese(() => { { var mockGen = SetupMock(); mockGen.Object.Within(fromDate, untilDate); mockGen.Verify(gen => gen.From(fromDate), Times.Once); mockGen.Verify(gen => gen.Until(untilDate), Times.Once); } { var mockGen = SetupMock(); mockGen.Object.Within(untilDate, fromDate); mockGen.Verify(gen => gen.From(fromDate), Times.Once); mockGen.Verify(gen => gen.Until(untilDate), Times.Once); } });