public void ensureFromModelViewCreatesSingleValueDimension()
        {
            AddSingleValueDimensionModelView singleValueDimensionModelView = new AddSingleValueDimensionModelView();

            singleValueDimensionModelView.value = 124;

            Dimension dimension = DimensionModelViewService.fromModelView(singleValueDimensionModelView);

            Type singleValueDimensionType = typeof(SingleValueDimension);

            Assert.Equal(singleValueDimensionType, dimension.GetType());
        }
        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 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);
        }