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 static void InitMeasureFuncComboBox(ASPxComboBox cbbMeasFunc, MeasureFunc measFuncDefault) { var restrictedTypes = new MeasureFunc[] { MeasureFunc.Avg, MeasureFunc.Max, MeasureFunc.Min, MeasureFunc.Sum }; foreach (var type in restrictedTypes) { cbbMeasFunc.Items.Add(type.ToString()); } cbbMeasFunc.SelectedItem = cbbMeasFunc.Items.FindByText(measFuncDefault.ToString()); }
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 static IGen <T> Unfold <T>( this IGen <T> gen, Func <T, IEnumerable <T> > shrinkValue, Func <T, decimal>?measureValue = null, Func <T, int>?identifyValue = null) { return(gen.Unfold(value => ExampleSpaceFactory.Unfold( value, shrinkValue.Invoke, measureValue == null ? MeasureFunc.Unmeasured <T>() : measureValue !.Invoke, identifyValue == null ? IdentifyFuncs.Default <T>() : value0 => ExampleId.Primitive(identifyValue !(value0))))); }
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"); });
public static void YGNodeSetMeasureFunc(YogaNode node, MeasureFunc measureFunc) => node.MeasureFunc = measureFunc;
public void SetMeasureFunc(MeasureFunc measureFunc) { Flex.SetMeasureFunc(this, measureFunc); }
private static IExampleSpace <T> UnfoldToNumberOfShrinks <T>(T value, int numberOfShrinks) => ExampleSpaceFactory.Unfold( value, new ShrinkNumberOfTimes <T>(numberOfShrinks), MeasureFunc.Unmeasured <T>(), (_) => RandomId());
public static YogaBuild Node( YogaConfig config = null, Direction direction = Direction.Inherit, FlexDirection flexDirection = FlexDirection.Column, Justify justifyContent = Justify.FlexStart, YogaAlign alignContent = YogaAlign.FlexStart, YogaAlign alignItems = YogaAlign.Stretch, YogaAlign alignSelf = YogaAlign.Auto, float aspectRatio = Net.YogaValue.YGUndefined, PositionType positionType = PositionType.Relative, Wrap flexWrap = Wrap.NoWrap, Overflow overflow = Overflow.Visible, Display display = Display.Flex, float flex = float.NaN, float flexGrow = float.NaN, float flexShrink = float.NaN, YogaValue flexBasis = null, // YogaValue.Auto, YogaValue width = null, // YogaValue.Auto, YogaValue height = null, // YogaValue.Auto, YogaValue minWidth = null, // YogaValue.Undefined, YogaValue minHeight = null, // YogaValue.Undefined, YogaValue maxWidth = null, // YogaValue.Undefined, YogaValue maxHeight = null, // YogaValue.Undefined, YogaValue left = null, YogaValue top = null, YogaValue right = null, YogaValue bottom = null, YogaValue start = null, YogaValue end = null, Edges margin = null, Edges position = null, Edges padding = null, Edges border = null, MeasureFunc measureFunc = null ) { var node = new YogaNode(config) { Style = new YogaStyle { Direction = direction, FlexDirection = flexDirection, JustifyContent = justifyContent, AlignContent = alignContent, AlignItems = alignItems, AlignSelf = alignSelf, AspectRatio = aspectRatio, PositionType = positionType, FlexWrap = flexWrap, Overflow = overflow, Display = display, Flex = flex, FlexGrow = flexGrow, FlexShrink = flexShrink, FlexBasis = flexBasis ?? YogaValue.Auto, Width = width ?? YogaValue.Auto, Height = height ?? YogaValue.Auto, MinWidth = minWidth ?? YogaValue.Undefined, MinHeight = minHeight ?? YogaValue.Undefined, MaxWidth = maxWidth ?? YogaValue.Undefined, MaxHeight = maxHeight ?? YogaValue.Undefined } }; if (margin != null) { node.Style.Margin = margin; } if (position != null) { node.Style.Position = position; } if (padding != null) { node.Style.Padding = padding; } if (border != null) { node.Style.Border = border; } if (start != null) { node.Style.Position.Start = start; } if (end != null) { node.Style.Position.End = end; } if (left != null) { node.Style.Left = left; } if (top != null) { node.Style.Top = top; } if (right != null) { node.Style.Right = right; } if (bottom != null) { node.Style.Bottom = bottom; } if (measureFunc != null) { node.MeasureFunc = measureFunc; } return(new YogaBuild(node)); }