Beispiel #1
0
        public void for_measure_dimension_defining_new_coeffiecient_units_should_throw_exception_when_basic_unit_is_not_defined_befor()
        {
            var centiMeter = new CoefficientMeasureUnitTestBuilder()
                             .WithSymbol(new Symbol(MeasureUnitSymbolTestData.CentiMeterUnitSymbol))
                             .WithTitle("سانتیمتر")
                             .WithRatioFromBasicMeasureUnit(0.01)
                             .BuildArg();

            var dimension = new MeasureDimensionTestBuilder()
                            .WithTitle("طول")
                            .Build();

            Action action = () => dimension.DefineCoefficientUnit(centiMeter);

            Check.ThatCode(action)
            .Throws <BasicMeasureUnitHasNotDefinedYetForThisDimension>();
        }
Beispiel #2
0
        public void measure_dimension_should_measure_coeffiecient_units_to_coeffiecient_units_properly()
        {
            var meter = new BasicMeasureUnitTestBuilder()
                        .WithSymbol(new Symbol(MeasureUnitSymbolTestData.MeterUnitSymbol))
                        .WithTitle("متر")
                        .BuildArg();

            var centiMeter = new CoefficientMeasureUnitTestBuilder()
                             .WithSymbol(new Symbol(MeasureUnitSymbolTestData.CentiMeterUnitSymbol))
                             .WithTitle("سانتیمتر")
                             .WithRatioFromBasicMeasureUnit(0.01)
                             .BuildArg();

            var kiloMeter = new CoefficientMeasureUnitTestBuilder()
                            .WithSymbol(new Symbol(MeasureUnitSymbolTestData.KiloMeterUnitSymbol))
                            .WithTitle("کیلومتر")
                            .WithRatioFromBasicMeasureUnit(1000)
                            .BuildArg();

            var dimension = new MeasureDimensionTestBuilder()
                            .WithTitle("طول")
                            .WithBasicMeasureUnitArg(meter)
                            .WithCoefficientMeasureUnitArg(centiMeter)
                            .WithCoefficientMeasureUnitArg(kiloMeter)
                            .Build();

            var arg = new MeasurementArg
            {
                FromValue      = 10,
                FromUnitSymbol = new Symbol(MeasureUnitSymbolTestData.KiloMeterUnitSymbol),
                ToUnitSymbol   = new Symbol(MeasureUnitSymbolTestData.CentiMeterUnitSymbol)
            };

            var expected = 1000000;

            var measuredValue = dimension.MeasureUnitsFor(arg, _formulaExpressionEvaluator);

            Check.That(measuredValue).IsEqualTo(expected);
        }
Beispiel #3
0
        public void measure_dimension_should_modify_coeffiecient_units_properly()
        {
            var basicUnit = new BasicMeasureUnitTestBuilder().BuildArg();

            var coefficientUnitBuilder = new CoefficientMeasureUnitTestBuilder();
            var coefficientUnit        = coefficientUnitBuilder.BuildArg();

            var dimension = new MeasureDimensionTestBuilder()
                            .WithBasicMeasureUnitArg(basicUnit)
                            .WithCoefficientMeasureUnitArg(coefficientUnit)
                            .Build();

            var arg = coefficientUnitBuilder
                      .WithTitle("new title")
                      .WithTitleSlug("new slug")
                      .WithRatioFromBasicMeasureUnit(0.0226)
                      .BuildArg();

            dimension.ModifyCoefficientUnit(arg);

            Check.That(dimension.MeasureUnits.First(c => c.Id == arg.Id))
            .Considering().All.Properties.IsEqualTo(arg);
        }
Beispiel #4
0
        public void for_measure_dimension_new_coeffiecient_units_should_be_defined_properly()
        {
            var meter = new BasicMeasureUnitTestBuilder()
                        .WithSymbol(new Symbol(MeasureUnitSymbolTestData.MeterUnitSymbol))
                        .WithTitle("متر")
                        .BuildArg();

            var centiMeterBuilder = new CoefficientMeasureUnitTestBuilder();
            var centiMeter        = centiMeterBuilder
                                    .WithSymbol(new Symbol(MeasureUnitSymbolTestData.CentiMeterUnitSymbol))
                                    .WithTitle("سانتیمتر")
                                    .WithRatioFromBasicMeasureUnit(0.01)
                                    .BuildArg();

            var dimension = new MeasureDimensionTestBuilder()
                            .WithBasicMeasureUnitArg(meter)
                            .Build();

            dimension.DefineCoefficientUnit(centiMeter);

            Check.That(dimension.MeasureUnits.First(c => c.Id == centiMeter.Id))
            .Considering().All.Properties.IsEqualTo(centiMeter);
        }