Esempio n. 1
0
        public void Examples(long value, long target, long[] expectedShrinks)
        {
            var func = ShrinkFunc.Towards(target);

            var shrinks = func(value);

            shrinks.Should().BeEquivalentTo(expectedShrinks);
        }
Esempio n. 2
0
        public IGen <Test> IfValueEqualsTarget_ItWillNotShrink() =>
        from value in Gen.Int32().Select(x => (long)x)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.Towards(value);

            var shrinks = func(value);

            shrinks.Should().BeEmpty();
        });
Esempio n. 3
0
        public IGen <Test> ItReflectsAroundZero() =>
        from value in Gen.Int32().GreaterThanEqual(0).Select(x => (long)x)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.Towards(0L);

            var shrinks          = func(value);
            var shrinksReflected = func(-value).Select(shrink => - shrink);

            shrinks.Should().BeEquivalentTo(shrinksReflected);
        });
Esempio n. 4
0
        public IGen <Test> ItWillNotProduceAShrinkEquallingTheValue() =>
        from value in Gen.Int32().Select(x => (long)x)
        from target in Gen.Int32().Select(x => (long)x)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.Towards(target);

            var shrinks = func(value);

            shrinks.Should().NotContain(value);
        });
Esempio n. 5
0
        public IGen <Test> ItWillProduceDistinctShrinks() =>
        from value in Gen.Int32().Select(x => (long)x)
        from target in Gen.Int32().Select(x => (long)x)
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.Towards(target);

            var shrinks = func(value);

            shrinks.Should().OnlyHaveUniqueItems();
        });
Esempio n. 6
0
        public IGen <Test> ItWillProduceAShrinkEquallingTheTargetFirst() =>
        from value in Gen.Int32().Select(x => (long)x)
        from target in Gen.Int32().Select(x => (long)x)
            where value != target
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.Towards(target);

            var shrinks = func(value);

            shrinks.First().Should().Be(target);
        });
Esempio n. 7
0
        public IGen <Test> ItWillProduceShrinksBetweenTheValueAndTarget() =>
        from value in Gen.Int32().Select(x => (long)x)
        from target in Gen.Int32().Select(x => (long)x)
            where value < target
        select Property.ForThese(() =>
        {
            var func = ShrinkFunc.Towards(target);

            var shrinks = func(value);

            shrinks.Should().NotBeEmpty();
            shrinks.ToList().ForEach(shrink => shrink.Should().BeInRange(value, target));
        });