public void ensureFromModelViewsThrowsExceptionIfEnumerableIsNull() { IEnumerable <AddDimensionModelView> dimensionModelViews = null; Action fromModelViews = () => DimensionModelViewService.fromModelViews(dimensionModelViews); Assert.Throws <ArgumentNullException>(fromModelViews); }
public void ensureFromModelViewsCreatesEnumerableOfDimensionWithExpectedData() { string unit = "m"; double minValue = 20; double maxValue = 120; double increment = 5; AddContinuousDimensionIntervalModelView continuousDimensionIntervalModelView = new AddContinuousDimensionIntervalModelView() { minValue = minValue, maxValue = maxValue, increment = increment, unit = unit }; List <double> values = new List <double>() { 12, 31, 45, 67 }; AddDiscreteDimensionIntervalModelView discreteDimensionIntervalModelView = new AddDiscreteDimensionIntervalModelView(); discreteDimensionIntervalModelView.values = values; discreteDimensionIntervalModelView.unit = unit; IEnumerable <AddDimensionModelView> modelViews = new List <AddDimensionModelView>() { continuousDimensionIntervalModelView, discreteDimensionIntervalModelView }; IEnumerable <Dimension> dimensions = DimensionModelViewService.fromModelViews(modelViews); Assert.Equal(modelViews.Count(), dimensions.Count()); var modelViewEnumerator = modelViews.GetEnumerator(); var dimensionEnumerator = dimensions.GetEnumerator(); for (int i = 0; i < modelViews.Count(); i++) { modelViewEnumerator.MoveNext(); dimensionEnumerator.MoveNext(); Assert.True(modelViewEqualsDimension(modelViewEnumerator.Current, dimensionEnumerator.Current)); } }
public void ensureFromModelViewsThrowsExceptionIfElementIsNull() { string unit = "m"; double minValue = 20; double maxValue = 120; double increment = 5; AddContinuousDimensionIntervalModelView continuousDimensionIntervalModelView = new AddContinuousDimensionIntervalModelView() { minValue = minValue, maxValue = maxValue, increment = increment, unit = unit }; List <double> values = new List <double>() { 12, 31, 45, 67 }; AddDiscreteDimensionIntervalModelView discreteDimensionIntervalModelView = new AddDiscreteDimensionIntervalModelView(); discreteDimensionIntervalModelView.values = values; discreteDimensionIntervalModelView.unit = unit; AddDimensionModelView nullModelView = null; IEnumerable <AddDimensionModelView> modelViews = new List <AddDimensionModelView>() { continuousDimensionIntervalModelView, discreteDimensionIntervalModelView, nullModelView }; Action fromModelViews = () => DimensionModelViewService.fromModelViews(modelViews); Assert.Throws <ArgumentNullException>(fromModelViews); }