Ejemplo n.º 1
0
        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);
        });
Ejemplo n.º 2
0
        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");
        });
Ejemplo n.º 3
0
        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);
            }
        });