private bool modelViewEqualsDimension(AddDimensionModelView modelView, Dimension dimension)
        {
            if (modelView.GetType() == typeof(AddDiscreteDimensionIntervalModelView) && dimension.GetType() == typeof(DiscreteDimensionInterval))
            {
                DiscreteDimensionInterval             discreteDimension = (DiscreteDimensionInterval)dimension;
                AddDiscreteDimensionIntervalModelView discreteModelView = (AddDiscreteDimensionIntervalModelView)modelView;

                List <double> expectedValues = new List <double>();

                foreach (double modelViewValue in discreteModelView.values)
                {
                    double expectedValue = MeasurementUnitService.convertFromUnit(modelViewValue, discreteModelView.unit);
                    expectedValues.Add(expectedValue);
                }

                var firstNotSecond = expectedValues.Except(discreteDimension.values.Select(dv => dv.value)).ToList();
                var secondNotFirst = discreteDimension.values.Select(dv => dv.value).Except(expectedValues).ToList();

                bool equalLists = !firstNotSecond.Any() && !secondNotFirst.Any();

                return(equalLists);
            }
            else if (modelView.GetType() == typeof(AddSingleValueDimensionModelView) && dimension.GetType() == typeof(SingleValueDimension))
            {
                SingleValueDimension             singleValueDimension = (SingleValueDimension)dimension;
                AddSingleValueDimensionModelView singleValueModelView = (AddSingleValueDimensionModelView)modelView;

                double expectedValue = MeasurementUnitService.convertFromUnit(singleValueModelView.value, singleValueModelView.unit);

                return(expectedValue.Equals(singleValueDimension.value));
            }
            else if (modelView.GetType() == typeof(AddContinuousDimensionIntervalModelView) && dimension.GetType() == typeof(ContinuousDimensionInterval))
            {
                ContinuousDimensionInterval             continuousDimension = (ContinuousDimensionInterval)dimension;
                AddContinuousDimensionIntervalModelView continuousModelView = (AddContinuousDimensionIntervalModelView)modelView;

                double expectedMinValue  = MeasurementUnitService.convertFromUnit(continuousModelView.minValue, continuousModelView.unit);
                double expectedMaxValue  = MeasurementUnitService.convertFromUnit(continuousModelView.maxValue, continuousModelView.unit);
                double expectedIncrement = MeasurementUnitService.convertFromUnit(continuousModelView.increment, continuousModelView.unit);

                return(expectedMinValue.Equals(continuousDimension.minValue) &&
                       expectedMaxValue.Equals(continuousDimension.maxValue) &&
                       expectedIncrement.Equals(continuousDimension.increment));
            }
            else
            {
                return(false);
            }
        }
        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);
        }