public void ExamplesForValuesBetweenOriginAndMax(int origin, int min, int max, int value, decimal expectedDistance) { var func = MeasureFunc.DistanceFromOrigin(origin, min, max); var distance = func(value); distance.Should().BeApproximately(expectedDistance, 1); }
public IGen <Test> IfOriginIsGreaterThanMax_ItThrows() => from min in Gen.Int32().LessThan(int.MaxValue) from max in Gen.Int32().GreaterThanEqual(min).LessThan(int.MaxValue) from origin in Gen.Int32().GreaterThan(max) select Property.ForThese(() => { Action action = () => MeasureFunc.DistanceFromOrigin(origin, min, max); action.Should() .Throw <ArgumentOutOfRangeException>() .And.ParamName.Should().Be("origin"); });
public IGen <Test> IfValueEqualsOrigin_ItReturnsZero() => from min in Gen.Int32() from max in Gen.Int32().GreaterThanEqual(min) from origin in Gen.Int32().Between(min, max) let value = origin select Property.ForThese(() => { var func = MeasureFunc.DistanceFromOrigin(origin, min, max); var distance = func(value); distance.Should().Be(0); });
public IGen <Test> IfValueEqualsMax_AndOriginDiffers_ItReturns100() => from min in Gen.Int32() from max in Gen.Int32().GreaterThanEqual(min) from origin in Gen.Int32().Between(min, max) where origin != max let value = max select Property.ForThese(() => { var func = MeasureFunc.DistanceFromOrigin(origin, min, max); var distance = func(value); distance.Should().Be(100); });
public IGen <Test> IfValueIsLessThanMin_ItThrows() => from min in Gen.Int32().GreaterThan(int.MinValue) from max in Gen.Int32().GreaterThanEqual(min) from origin in Gen.Int32().Between(min, max) from value in Gen.Int32().LessThan(min) select Property.ForThese(() => { var func = MeasureFunc.DistanceFromOrigin(origin, min, max); Action action = () => func(value); action.Should() .Throw <ArgumentOutOfRangeException>() .And.ParamName.Should().Be("value"); });