Пример #1
0
        public void SpeedSimple()
        {
            Length   L1 = new Length(100, LengthUnit.Meter);
            Duration D1 = new Duration(10, DurationUnit.Second);

            Speed S1 = L1 / D1;


            Assert.AreEqual(10, (double)S1.As(SpeedUnit.MeterPerSecond));
            Assert.AreEqual(36, (double)S1.As(SpeedUnit.KilometerPerhour));
            Assert.AreEqual(10.936132983377078, (double)S1.As(SpeedUnit.YardPerSecond));
        }
Пример #2
0
        public void SpeedSimple2()
        {
            Length   L1 = new Length(100, LengthUnit.Yard);
            Duration D1 = new Duration(10, DurationUnit.Hour);

            Speed S1 = L1 / D1;


            Assert.AreEqual(0.00254, (double)S1.As(SpeedUnit.MeterPerSecond));
            Assert.AreEqual(0.009144, (double)S1.As(SpeedUnit.KilometerPerhour));
            Assert.AreEqual(0.002777777777777778, (double)S1.As(SpeedUnit.YardPerSecond));
            Assert.AreEqual(0.1, (double)S1.As(SpeedUnit.InchPerSecond));
        }
Пример #3
0
        public string Calculate(DSTCalculation data, DSTCalculationType type)
        {
            switch (type)
            {
            case DSTCalculationType.Speed:
                Speed speed = CalculateSpeed(data);
                return($"Speed = {speed.As(data.SpeedUnit)}{Speed.GetAbbreviation(data.SpeedUnit)}");

            case DSTCalculationType.Distance:
                Length distance = CalculateDistance(data);
                return($"Distance = {distance.As(data.DistanceUnit)} {Length.GetAbbreviation(data.DistanceUnit)}");

            case DSTCalculationType.Time:
                TimeSpan time = CalculateTime(data);

                return($"Time = {FormatTime(time)} ");

            default:
                throw new Exception("Unsupported Action");
            }
        }