Exemplo n.º 1
0
        /// <summary>
        /// Builds a DimensionDTO out of a SingleValueDimension instance
        /// </summary>
        /// <returns>DimensionDTO instance</returns>
        public override DimensionDTO toDTO()
        {
            SingleValueDimensionDTO dto = new SingleValueDimensionDTO();

            dto.id    = Id;
            dto.value = value;
            dto.unit  = MeasurementUnitService.getMinimumUnit();

            return(dto);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Builds a CustomizedDimensionsDTO out of a CustomizedDimensions instance
        /// </summary>
        /// <returns>CustomizedDimensionsDTO instance</returns>
        public CustomizedDimensionsDTO toDTO()
        {
            CustomizedDimensionsDTO customizedDimensionsDTO = new CustomizedDimensionsDTO();

            customizedDimensionsDTO.Id     = this.Id;
            customizedDimensionsDTO.width  = width;
            customizedDimensionsDTO.depth  = depth;
            customizedDimensionsDTO.height = height;
            customizedDimensionsDTO.unit   = MeasurementUnitService.getMinimumUnit();
            return(customizedDimensionsDTO);
        }
        public void ensureFromCollectionWithEmptyUnitUsesMinimumUnit()
        {
            double    minValue  = 20;
            double    maxValue  = 60;
            double    increment = 2;
            Dimension continuousDimensionInterval = new ContinuousDimensionInterval(minValue, maxValue, increment);

            List <double> values = new List <double>()
            {
                21, 35, 42
            };
            Dimension discreteDimensionInterval = new DiscreteDimensionInterval(values);

            double    value = 72;
            Dimension singleValueDimension = new SingleValueDimension(value);

            IEnumerable <Dimension> dimensions = new List <Dimension>()
            {
                continuousDimensionInterval, discreteDimensionInterval, singleValueDimension
            };

            GetAllDimensionsModelView getAllDimensionsModelView = DimensionModelViewService.fromCollection(dimensions, "");

            string minimumUnit = MeasurementUnitService.getMinimumUnit();

            GetContinuousDimensionIntervalModelView continuousDimensionIntervalModelView = new GetContinuousDimensionIntervalModelView();

            continuousDimensionIntervalModelView.minValue  = minValue;
            continuousDimensionIntervalModelView.maxValue  = maxValue;
            continuousDimensionIntervalModelView.increment = increment;
            continuousDimensionIntervalModelView.unit      = minimumUnit;


            GetDiscreteDimensionIntervalModelView discreteDimensionIntervalModelView = new GetDiscreteDimensionIntervalModelView();

            discreteDimensionIntervalModelView.values = values;
            discreteDimensionIntervalModelView.unit   = minimumUnit;


            GetSingleValueDimensionModelView singleValueDimensionModelView = new GetSingleValueDimensionModelView();

            singleValueDimensionModelView.value = value;
            singleValueDimensionModelView.unit  = minimumUnit;

            GetAllDimensionsModelView expected = new GetAllDimensionsModelView()
            {
                continuousDimensionIntervalModelView, discreteDimensionIntervalModelView, singleValueDimensionModelView
            };

            for (int i = 0; i < 3; i++)
            {
                Assert.True(equalModelViews(getAllDimensionsModelView[i], expected[i]));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Builds a DimensionDTO out of a ContinuousDimensionInterval instance
        /// </summary>
        /// <returns>DimensionDTO instance</returns>
        public override DimensionDTO toDTO()
        {
            ContinuousDimensionIntervalDTO dto = new ContinuousDimensionIntervalDTO();

            dto.id        = Id;
            dto.unit      = MeasurementUnitService.getMinimumUnit();
            dto.minValue  = minValue;
            dto.maxValue  = maxValue;
            dto.increment = increment;

            return(dto);
        }
        public void ensureFromEntityWithEmptyUnitUsesMinimumUnit()
        {
            double minWidth         = 25;
            double maxWidth         = 50;
            double recommendedWidth = 35;

            ProductSlotWidths slotWidths = ProductSlotWidths.valueOf(minWidth, maxWidth, recommendedWidth);

            GetProductSlotWidthsModelView result = ProductSlotWidthsModelViewService.fromEntity(slotWidths, "");

            string expectedUnit = MeasurementUnitService.getMinimumUnit();

            Assert.Equal(expectedUnit, result.unit);
        }
        public void ensureFromEntityConvertsSingleValueDimension()
        {
            Dimension singleValueDimension = new SingleValueDimension(15);

            GetDimensionModelView getDimensionModelView = DimensionModelViewService.fromEntity(singleValueDimension);

            GetSingleValueDimensionModelView expected = new GetSingleValueDimensionModelView();

            expected.value = 15;
            expected.unit  = MeasurementUnitService.getMinimumUnit();

            GetSingleValueDimensionModelView result = (GetSingleValueDimensionModelView)getDimensionModelView;

            Assert.Equal(expected.value, result.value);
            Assert.Equal(expected.unit, result.unit);
        }
        public void ensureFromEntityWithEmptyUnitUsesMinimumUnit()
        {
            double value = 15;

            Dimension singleValueDimension = new SingleValueDimension(value);

            string unit = "";

            GetDimensionModelView getDimensionModelView = DimensionModelViewService.fromEntity(singleValueDimension, unit);

            GetSingleValueDimensionModelView expected = new GetSingleValueDimensionModelView();

            expected.value = value;
            expected.unit  = MeasurementUnitService.getMinimumUnit();

            GetSingleValueDimensionModelView result = (GetSingleValueDimensionModelView)getDimensionModelView;

            Assert.Equal(expected.value, result.value);
            Assert.Equal(expected.unit, result.unit);
        }
        public void ensureFromEntityConvertsDiscreteDimensionInterval()
        {
            List <double> values = new List <double>()
            {
                21, 35, 42
            };

            Dimension discreteDimensionInterval = new DiscreteDimensionInterval(values);

            GetDimensionModelView getDimensionModelView = DimensionModelViewService.fromEntity(discreteDimensionInterval);

            GetDiscreteDimensionIntervalModelView result = (GetDiscreteDimensionIntervalModelView)getDimensionModelView;

            GetDiscreteDimensionIntervalModelView expected = new GetDiscreteDimensionIntervalModelView();

            expected.values = values;
            expected.unit   = MeasurementUnitService.getMinimumUnit();

            Assert.Equal(expected.values, result.values);
            Assert.Equal(expected.unit, result.unit);
        }
        public void ensureFromEntityCreatesModelViewWithExpectedData()
        {
            double minWidth         = 25;
            double maxWidth         = 50;
            double recommendedWidth = 35;

            ProductSlotWidths slotWidths = ProductSlotWidths.valueOf(minWidth, maxWidth, recommendedWidth);

            GetProductSlotWidthsModelView result = ProductSlotWidthsModelViewService.fromEntity(slotWidths);

            GetProductSlotWidthsModelView expected = new GetProductSlotWidthsModelView();

            expected.minWidth         = minWidth;
            expected.maxWidth         = maxWidth;
            expected.recommendedWidth = recommendedWidth;
            expected.unit             = MeasurementUnitService.getMinimumUnit();

            Assert.Equal(expected.minWidth, result.minWidth);
            Assert.Equal(expected.maxWidth, result.maxWidth);
            Assert.Equal(expected.recommendedWidth, result.recommendedWidth);
            Assert.Equal(expected.unit, result.unit);
        }
        public void ensureFromEntityConvertsContinuousDimensionInterval()
        {
            double minValue  = 20;
            double maxValue  = 60;
            double increment = 2;

            Dimension continuousDimensionInterval = new ContinuousDimensionInterval(minValue, maxValue, increment);

            GetDimensionModelView getDimensionModelView = DimensionModelViewService.fromEntity(continuousDimensionInterval);

            GetContinuousDimensionIntervalModelView result = (GetContinuousDimensionIntervalModelView)getDimensionModelView;

            GetContinuousDimensionIntervalModelView expected = new GetContinuousDimensionIntervalModelView();

            expected.minValue  = minValue;
            expected.maxValue  = maxValue;
            expected.increment = increment;
            expected.unit      = MeasurementUnitService.getMinimumUnit();

            Assert.Equal(expected.minValue, result.minValue);
            Assert.Equal(expected.maxValue, result.maxValue);
            Assert.Equal(expected.increment, result.increment);
            Assert.Equal(expected.unit, result.unit);
        }
Exemplo n.º 11
0
 public void ensureGetMinimumUnitSucceeds()
 {
     Console.WriteLine("ensureGetMinimumUnitSucceds");
     Assert.Equal("mm", MeasurementUnitService.getMinimumUnit());
 }
 /// <summary>
 /// Converts an IEnumerable of Slot into an instance of GetAllSlotsModelView.
 /// </summary>
 /// <param name="slots">IEnumerable of Slot being converted.</param>
 /// <returns>An instance of GetAllSlotsModelView representing all of the Slots in the IEnumerable.</returns>
 public static GetAllSlotsModelView fromCollection(IEnumerable <Slot> slots)
 {
     return(fromCollection(slots, MeasurementUnitService.getMinimumUnit()));
 }
 /// <summary>
 /// Converts an instance of CustomizedDimensions into an instance of GetCustomizedModelView.
 /// </summary>
 /// <param name="customizedDimensions">Instance of CustomizedDimensions.</param>
 /// <returns>The created instance of GetCustomizedDimensionsModelView.</returns>
 /// <exception cref="System.ArgumentException">Thrown when the provided CustomizedDimensions is null.</exception>
 public static GetCustomizedDimensionsModelView fromEntity(CustomizedDimensions customizedDimensions)
 {
     return(fromEntity(customizedDimensions, MeasurementUnitService.getMinimumUnit()));
 }
 /// <summary>
 /// Converts an instance of Measurement into an instance of GetMeasurementModelView.
 /// </summary>
 /// <param name="measurement">Measurement being converted.</param>
 /// <returns>An instance of GetMeasurementModelView with the Measurement data.</returns>
 /// <exception cref="System.ArgumentNullException">If the provided Measurement is null.</exception>
 public static GetMeasurementModelView fromEntity(Measurement measurement)
 {
     return(fromEntity(measurement, MeasurementUnitService.getMinimumUnit()));
 }
 /// <summary>
 /// Creates a model view with the information about a collection of dimension
 /// </summary>
 /// <param name="dimensions">IEnumerable with the collection of dimensions</param>
 /// <returns>GetAllDimensionsModelView with the collection of dimensions model view</returns>
 /// <exception cref="System.ArgumentNullException">Throw when the provided IEnumerable of Dimension is null.</exception>
 public static GetAllDimensionsModelView fromCollection(IEnumerable <Dimension> dimensions)
 {
     return(fromCollection(dimensions, MeasurementUnitService.getMinimumUnit()));
 }
 /// <summary>
 /// Creates a model view with a dimension information
 /// </summary>
 /// <param name="dimension">Dimension with the dimension being created the model view</param>
 /// <returns>GetDimensionModelView with the dimension information model view</returns>
 /// <exception cref="System.ArgumentNullException">Throw when the provided Dimension is null.</exception>
 public static GetDimensionModelView fromEntity(Dimension dimension)
 {
     return(fromEntity(dimension, MeasurementUnitService.getMinimumUnit()));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Converts an instance of CustomizedProduct into an instance of GetCustomizedProductModelView.
 /// </summary>
 /// <param name="customizedProduct">Instance of CustomizedProduct being converted.</param>
 /// <returns>Instance of GetCustomizedProductModelView.</returns>
 /// <exception cref="System.ArgumentException">Thrown when the provided instance of CustomizedProduct is null.</exception>
 public static GetCustomizedProductModelView fromEntity(CustomizedProduct customizedProduct)
 {
     return(fromEntity(customizedProduct, MeasurementUnitService.getMinimumUnit()));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Converts an instance of ProductSlotWidths into an instance of GetProductSlotWidthsModelView.
 /// </summary>
 /// <param name="productSlotWidths">Instance of ProductSlotWidths.</param>
 /// <returns>The created instance of GetProductSlotWidthsModelView.</returns>
 /// <exception cref="System.ArgumentNullException">Thrown when the provided instance of ProductSlotWidths is null.</exception>
 public static GetProductSlotWidthsModelView fromEntity(ProductSlotWidths productSlotWidths)
 {
     return(fromEntity(productSlotWidths, MeasurementUnitService.getMinimumUnit()));
 }
 /// <summary>
 /// Converts an instance of Slot into an instance of GetSlotModelView.
 /// </summary>
 /// <param name="slot">Instance of Slot being converted.</param>
 /// <returns>Instance of GetSlotModelView.</returns>
 /// <exception cref="System.ArgumentException">Thrown when the provided instance of Slot is null.</exception>
 public static GetSlotModelView fromEntity(Slot slot)
 {
     return(fromEntity(slot, MeasurementUnitService.getMinimumUnit()));
 }
 /// <summary>
 /// Converts an IEnumerable of CustomizedDimensions into an instance of GetAllCustomizedDimensionsModelView.
 /// </summary>
 /// <param name="customizedDimensions">IEnumerable of CustomizedDimensions.</param>
 /// <exception cref="System.ArgumentException">Thrown when the provided IEnumerable of CustomizedDimensions is null.</exception>
 /// <returns>Instance of GetAllCustomizedDimensionsModelView.</returns>
 public static GetAllCustomizedDimensionsModelView fromCollection(IEnumerable <CustomizedDimensions> customizedDimensions)
 {
     return(fromCollection(customizedDimensions, MeasurementUnitService.getMinimumUnit()));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Creates a model view with a product information.
 /// </summary>
 /// <param name="product">Product with the product being created the model view.</param>
 /// <returns>GetProductModelView with the product information model view</returns>
 public static GetProductModelView fromEntity(Product product)
 {
     return(fromEntity(product, MeasurementUnitService.getMinimumUnit()));
 }