public void Examples(long value, long target, long[] expectedShrinks) { var func = ShrinkFunc.Towards(target); var shrinks = func(value); shrinks.Should().BeEquivalentTo(expectedShrinks); }
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(); });
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); });
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); });
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(); });
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); });
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)); });