public void ensureFromModelViewCreatesSingleValueDimension() { AddSingleValueDimensionModelView singleValueDimensionModelView = new AddSingleValueDimensionModelView(); singleValueDimensionModelView.value = 124; Dimension dimension = DimensionModelViewService.fromModelView(singleValueDimensionModelView); Type singleValueDimensionType = typeof(SingleValueDimension); Assert.Equal(singleValueDimensionType, dimension.GetType()); }
/// <summary> /// Creates an instance of Measurement from an AddMeasurementModelView instance. /// </summary> /// <param name="measurementModelView">AddMeasurementModelView instance.</param> /// <returns>Created Measurement.</returns> public static Measurement fromModelView(AddMeasurementModelView measurementModelView) { if (measurementModelView == null) { throw new ArgumentException(ERROR_NULL_MEASUREMENT_VIEW); } Dimension heightDimension = DimensionModelViewService.fromModelView(measurementModelView.heightDimension); Dimension widthDimension = DimensionModelViewService.fromModelView(measurementModelView.widthDimension); Dimension depthDimension = DimensionModelViewService.fromModelView(measurementModelView.depthDimension); return(new Measurement(heightDimension, widthDimension, depthDimension)); }
public void ensureFromModelViewCreatesContinuousDimensionInterval() { AddContinuousDimensionIntervalModelView continuousDimensionIntervalModelView = new AddContinuousDimensionIntervalModelView(); continuousDimensionIntervalModelView.minValue = 25; continuousDimensionIntervalModelView.maxValue = 45; continuousDimensionIntervalModelView.increment = 5; Dimension dimension = DimensionModelViewService.fromModelView(continuousDimensionIntervalModelView); Type continuousDimensionIntervalType = typeof(ContinuousDimensionInterval); Assert.Equal(continuousDimensionIntervalType, dimension.GetType()); }
public void ensureFromModelViewCreatesDiscreteDimensionInterval() { AddDiscreteDimensionIntervalModelView discreteDimensionIntervalModelView = new AddDiscreteDimensionIntervalModelView(); discreteDimensionIntervalModelView.values = new List <double>() { 12, 31, 45, 67 }; Dimension dimension = DimensionModelViewService.fromModelView(discreteDimensionIntervalModelView); Type discreteDimensionIntervalType = typeof(DiscreteDimensionInterval); Assert.Equal(discreteDimensionIntervalType, dimension.GetType()); }
public void ensureFromModelViewCreatesSingleValueDimensionWithExpectedData() { double value = 25; string unit = "dm"; AddSingleValueDimensionModelView singleValueDimensionModelView = new AddSingleValueDimensionModelView(); singleValueDimensionModelView.value = value; singleValueDimensionModelView.unit = unit; SingleValueDimension singleValueDimension = (SingleValueDimension)DimensionModelViewService.fromModelView(singleValueDimensionModelView); double expectedValue = MeasurementUnitService.convertFromUnit(value, unit); Assert.Equal(expectedValue, singleValueDimension.value); }
public void ensureFromModelViewCreatesDiscreteDimensionIntervalWithExpectedData() { List <double> values = new List <double>() { 12, 31, 45, 67 }; string unit = "cm"; AddDiscreteDimensionIntervalModelView discreteDimensionIntervalModelView = new AddDiscreteDimensionIntervalModelView(); discreteDimensionIntervalModelView.values = values; discreteDimensionIntervalModelView.unit = unit; DiscreteDimensionInterval discreteDimensionInterval = (DiscreteDimensionInterval)DimensionModelViewService.fromModelView(discreteDimensionIntervalModelView); for (int i = 0; i < values.Count; i++) { double expectedValue = MeasurementUnitService.convertFromUnit(values[i], unit); Assert.Equal(expectedValue, discreteDimensionInterval.values[i].value); } }
public void ensureFromModelViewCreatesContinuousDimensionIntervalWithExpectedData() { double minValue = 20; double maxValue = 120; double increment = 5; string unit = "m"; AddContinuousDimensionIntervalModelView continuousDimensionIntervalModelView = new AddContinuousDimensionIntervalModelView() { minValue = minValue, maxValue = maxValue, increment = increment, unit = unit }; ContinuousDimensionInterval continuousDimensionInterval = (ContinuousDimensionInterval)DimensionModelViewService.fromModelView(continuousDimensionIntervalModelView); double expectedMinValue = MeasurementUnitService.convertFromUnit(minValue, unit); double expectedMaxvalue = MeasurementUnitService.convertFromUnit(maxValue, unit); double expectedIncrement = MeasurementUnitService.convertFromUnit(increment, unit); Assert.Equal(expectedMinValue, continuousDimensionInterval.minValue); Assert.Equal(expectedMaxvalue, continuousDimensionInterval.maxValue); Assert.Equal(expectedIncrement, continuousDimensionInterval.increment); }
public void ensureFromModelViewThrowsExceptionIfModelViewIsNull() { Action fromModelView = () => DimensionModelViewService.fromModelView(null); Assert.Throws <ArgumentNullException>(fromModelView); }