public UnitPartsConverterSource()
        {
            var settings = MockSettings.Create();

            this.Metres    = settings.Metres;
            this.Kilograms = settings.Kilograms;
            this.Seconds   = settings.Seconds;
            this._datas    = new List <Data>
            {
                new Data("m^2", "m²", UnitAndPower.Create(this.Metres, 2)),
                new Data("m²", "m²", UnitAndPower.Create(this.Metres, 2)),
                new Data("m³", "m³", UnitAndPower.Create(this.Metres, 3)),
                new Data("kg⋅m/s²", "kg⋅m/s²", UnitAndPower.Create(this.Kilograms, 1), UnitAndPower.Create(this.Metres, 1), UnitAndPower.Create(this.Seconds, -2)),
                new Data("kg⋅m⋅s⁻²", "kg⋅m/s²", UnitAndPower.Create(this.Kilograms, 1), UnitAndPower.Create(this.Metres, 1), UnitAndPower.Create(this.Seconds, -2)),
                new Data("kg*m/s²", "kg⋅m/s²", UnitAndPower.Create(this.Kilograms, 1), UnitAndPower.Create(this.Metres, 1), UnitAndPower.Create(this.Seconds, -2)),
                new Data("m/s¹", "m/s", UnitAndPower.Create(this.Metres, 1), UnitAndPower.Create(this.Seconds, -1)),
                new Data("m⋅s⁻¹", "m/s", UnitAndPower.Create(this.Metres, 1), UnitAndPower.Create(this.Seconds, -1)),
                new Data("m¹⋅s^-1", "m/s", UnitAndPower.Create(this.Metres, 1), UnitAndPower.Create(this.Seconds, -1)),
                new Data("m^1⋅s^-1", "m/s", UnitAndPower.Create(this.Metres, 1), UnitAndPower.Create(this.Seconds, -1)),
                new Data("m¹⋅s⁻¹", "m/s", UnitAndPower.Create(this.Metres, 1), UnitAndPower.Create(this.Seconds, -1)),
                new Data("1/s", "s⁻¹", UnitAndPower.Create(this.Seconds, -1)),
                new Data("s^-1", "s⁻¹", UnitAndPower.Create(this.Seconds, -1))
                //new Data("J/s",UnitAndPower.Create(Joules, 1),UnitAndPower.Create(Seconds, -1)),
            };
        }
Esempio n. 2
0
 public static void SetUnitToKilograms()
 {
     using var settings = MockSettings.Create();
     using var vm       = new PartConversionsVm();
     vm.SetUnit(settings.Kilograms);
     CollectionAssert.IsEmpty(vm.Conversions);
 }
Esempio n. 3
0
 public static void SetUnitToMetresPerSecond()
 {
     Assert.Inconclusive();
     //// ReSharper disable once HeuristicUnreachableCode
     using var settings = MockSettings.Create();
     using var vm       = new PartConversionsVm();
     vm.SetUnit(settings.MetresPerSecond);
     CollectionAssert.IsEmpty(vm.Conversions);
 }
Esempio n. 4
0
        public static void MetresToUnitString(int power, string expected)
        {
            using var settings = MockSettings.Create();
            var parts = new[] { UnitAndPower.Create(settings.Metres, power) };

            var actual = parts.AsSymbol();

            Assert.AreEqual(expected, actual);
        }
Esempio n. 5
0
        public void SetUnitToMetresPerSecond()
        {
            Assert.Inconclusive();
            var settings = MockSettings.Create();
            var vm       = new PartConversionsVm(settings);

            vm.SetUnit(settings.MetresPerSecond);
            CollectionAssert.AreEqual(new PartConversionsVm[0], vm.Conversions);
        }
Esempio n. 6
0
        public async Task FactorConversion()
        {
            var settings   = MockSettings.Create();
            var conversion = new FactorConversion("Inches", "in", 0.0254);

            settings.Metres.FactorConversions.Add(conversion);
            Assert.AreEqual("0.0254 * inches", conversion.ToSi);
            Assert.AreEqual("metres / 0.0254", conversion.FromSi);
            Assert.AreEqual("1 in = 0.0254 m", await conversion.GetSymbolConversionAsync().ConfigureAwait(false));
            Assert.AreEqual(true, await conversion.CanRoundtripAsync().ConfigureAwait(false));
        }
Esempio n. 7
0
        public async Task PrefixMicroConversion()
        {
            var settings   = MockSettings.Create();
            var conversion = PrefixConversion.Create(settings.Metres, settings.Micro);

            settings.Metres.PrefixConversions.Add(conversion);
            Assert.AreEqual("micrometres / 1000000", conversion.ToSi);
            Assert.AreEqual("1000000 * metres", conversion.FromSi);
            Assert.AreEqual("1 µm = 1E-06 m", await conversion.GetSymbolConversionAsync().ConfigureAwait(false));
            Assert.AreEqual(true, await conversion.CanRoundtripAsync().ConfigureAwait(false));
        }
Esempio n. 8
0
        public void MetresPerSecondCubed()
        {
            var settings   = MockSettings.Create();
            var metrePart  = PartConversion.CreatePart(1, settings.Metres);
            var secondPart = PartConversion.CreatePart(-2, settings.Seconds);
            var conversion = PartConversion.Create(settings.MetresPerSecondSquared, metrePart, secondPart);

            Assert.AreEqual("m/s²", conversion.Symbol);
            Assert.AreEqual("MetresPerSecondSquared", conversion.Name);
            Assert.AreEqual(1, conversion.Factor);
            Assert.AreEqual(true, conversion.CanRoundtrip);
        }
Esempio n. 9
0
        public static void SecondsMetresToUnitString()
        {
            using var settings = MockSettings.Create();
            var parts = new[]
            {
                UnitAndPower.Create(settings.Seconds, -1),
                UnitAndPower.Create(settings.Metres, 1),
            };

            var actual = parts.AsSymbol();

            Assert.AreEqual("m/s", actual);
        }