Esempio n. 1
0
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = TemperatureCoefficient.FromPercentageByKelvins(1);

            Assert.True(v.Equals(TemperatureCoefficient.FromPercentageByKelvins(1), PercentageByKelvinsTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(TemperatureCoefficient.Zero, PercentageByKelvinsTolerance, ComparisonType.Relative));
        }
Esempio n. 2
0
        public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit()
        {
            var quantity = new TemperatureCoefficient();

            Assert.Equal(0, quantity.Value);
            Assert.Equal(TemperatureCoefficientUnit.PercentageByKelvin, quantity.Unit);
        }
Esempio n. 3
0
        public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
        {
            var quantity00 = TemperatureCoefficient.From(1, TemperatureCoefficientUnit.PercentageByKelvin);

            AssertEx.EqualTolerance(1, quantity00.PercentageByKelvins, PercentageByKelvinsTolerance);
            Assert.Equal(TemperatureCoefficientUnit.PercentageByKelvin, quantity00.Unit);
        }
        /// <summary>
        /// Constructeur vide par défaut
        /// </summary>
        public MainWindowViewModel()
        {
            Multiples  = Multiple.GetMultiples();
            Tolerances = Tolerance.GetTolerances();
            TemperatureCoefficients = TemperatureCoefficient.GetTemperatureCoefficients();
            ESeries       = ESerie.GetESeries();
            ResistorRings = ResistorRing.GetResistorRings();
            Rings1        = Ring.GetRings().Where(x => x.Digit != null).OrderBy(x => x.DigitOrder).ToList();
            Rings2        = Ring.GetRings().Where(x => x.Digit != null).OrderBy(x => x.DigitOrder).ToList();
            Rings3        = Ring.GetRings().Where(x => x.Digit != null).OrderBy(x => x.DigitOrder).ToList();
            Rings4        = Ring.GetRings().Where(x => x.Multiplicator != null).OrderBy(x => x.MultiplicatorOrder).ToList();
            Rings5        = Ring.GetRings().Where(x => x.Tolerance != null).OrderBy(x => x.ToleranceOrder).ToList();
            Rings6        = Ring.GetRings().Where(x => x.TemperatureCoefficient != null).OrderBy(x => x.TemperatureCoefficientOrder).ToList();

            Ring        blackRing = Rings1.Where(x => x.Digit == 0).Single();
            List <Ring> except    = new List <Ring>()
            {
                blackRing
            };

            SetRing5Color(Rings5.OrderBy(a => a.Tolerance.Index == 2).First());
            SetRing1Color(Rings1.Except(except).ToList().OrderBy(a => Guid.NewGuid()).First());
            SetRing2Color(Rings2.OrderBy(a => Guid.NewGuid()).First());
            SetRing4Color(Rings4.OrderBy(a => Guid.NewGuid()).First());
        }
Esempio n. 5
0
        public void Equals_SameType_IsImplemented()
        {
            var a = TemperatureCoefficient.FromPercentageByKelvins(1);
            var b = TemperatureCoefficient.FromPercentageByKelvins(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
Esempio n. 6
0
        public void CompareToIsImplemented()
        {
            TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1);

            Assert.Equal(0, percentagebykelvin.CompareTo(percentagebykelvin));
            Assert.True(percentagebykelvin.CompareTo(TemperatureCoefficient.Zero) > 0);
            Assert.True(TemperatureCoefficient.Zero.CompareTo(percentagebykelvin) < 0);
        }
Esempio n. 7
0
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = TemperatureCoefficient.FromPercentageByKelvins(1);
            object b = TemperatureCoefficient.FromPercentageByKelvins(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
Esempio n. 8
0
        public void ToUnit()
        {
            var percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1);

            var percentagebykelvinQuantity = percentagebykelvin.ToUnit(TemperatureCoefficientUnit.PercentageByKelvin);

            AssertEx.EqualTolerance(PercentageByKelvinsInOnePercentageByKelvin, (double)percentagebykelvinQuantity.Value, PercentageByKelvinsTolerance);
            Assert.Equal(TemperatureCoefficientUnit.PercentageByKelvin, percentagebykelvinQuantity.Unit);
        }
Esempio n. 9
0
        /// <summary>
        /// Get the significant details of what needs approval
        /// </summary>
        /// <returns>A list of strings</returns>
        public override IDictionary <string, string> SignificantDetails()
        {
            IDictionary <string, string> returnList = base.SignificantDetails();

            returnList.Add("Temperature", TemperatureCoefficient.ToString());
            returnList.Add("Pressure", PressureCoefficient.ToString());
            returnList.Add("Biome", BaseBiome.ToString());
            returnList.Add("Hemisphere", Hemisphere.ToString());

            return(returnList);
        }
Esempio n. 10
0
        public void ArithmeticOperators()
        {
            TemperatureCoefficient v = TemperatureCoefficient.FromPercentageByKelvins(1);

            AssertEx.EqualTolerance(-1, -v.PercentageByKelvins, PercentageByKelvinsTolerance);
            AssertEx.EqualTolerance(2, (TemperatureCoefficient.FromPercentageByKelvins(3) - v).PercentageByKelvins, PercentageByKelvinsTolerance);
            AssertEx.EqualTolerance(2, (v + v).PercentageByKelvins, PercentageByKelvinsTolerance);
            AssertEx.EqualTolerance(10, (v * 10).PercentageByKelvins, PercentageByKelvinsTolerance);
            AssertEx.EqualTolerance(10, (10 * v).PercentageByKelvins, PercentageByKelvinsTolerance);
            AssertEx.EqualTolerance(2, (TemperatureCoefficient.FromPercentageByKelvins(10) / 5).PercentageByKelvins, PercentageByKelvinsTolerance);
            AssertEx.EqualTolerance(2, TemperatureCoefficient.FromPercentageByKelvins(10) / TemperatureCoefficient.FromPercentageByKelvins(5), PercentageByKelvinsTolerance);
        }
Esempio n. 11
0
        public void ComparisonOperators()
        {
            TemperatureCoefficient onePercentageByKelvin  = TemperatureCoefficient.FromPercentageByKelvins(1);
            TemperatureCoefficient twoPercentageByKelvins = TemperatureCoefficient.FromPercentageByKelvins(2);

            Assert.True(onePercentageByKelvin < twoPercentageByKelvins);
            Assert.True(onePercentageByKelvin <= twoPercentageByKelvins);
            Assert.True(twoPercentageByKelvins > onePercentageByKelvin);
            Assert.True(twoPercentageByKelvins >= onePercentageByKelvin);

            Assert.False(onePercentageByKelvin > twoPercentageByKelvins);
            Assert.False(onePercentageByKelvin >= twoPercentageByKelvins);
            Assert.False(twoPercentageByKelvins < onePercentageByKelvin);
            Assert.False(twoPercentageByKelvins <= onePercentageByKelvin);
        }
Esempio n. 12
0
        public void EqualityOperators()
        {
            var a = TemperatureCoefficient.FromPercentageByKelvins(1);
            var b = TemperatureCoefficient.FromPercentageByKelvins(2);

            // ReSharper disable EqualExpressionComparison

            Assert.True(a == a);
            Assert.False(a != a);

            Assert.True(a != b);
            Assert.False(a == b);

            Assert.False(a == null);
            Assert.False(null == a);

// ReSharper restore EqualExpressionComparison
        }
Esempio n. 13
0
        public void TemperatureCoefficient_QuantityInfo_ReturnsQuantityInfoDescribingQuantity()
        {
            var quantity = new TemperatureCoefficient(1, TemperatureCoefficientUnit.PercentageByKelvin);

            QuantityInfo <TemperatureCoefficientUnit> quantityInfo = quantity.QuantityInfo;

            Assert.Equal(TemperatureCoefficient.Zero, quantityInfo.Zero);
            Assert.Equal("TemperatureCoefficient", quantityInfo.Name);
            Assert.Equal(QuantityType.TemperatureCoefficient, quantityInfo.QuantityType);

            var units     = EnumUtils.GetEnumValues <TemperatureCoefficientUnit>().Except(new[] { TemperatureCoefficientUnit.Undefined }).ToArray();
            var unitNames = units.Select(x => x.ToString());

            // Obsolete members
#pragma warning disable 618
            Assert.Equal(units, quantityInfo.Units);
            Assert.Equal(unitNames, quantityInfo.UnitNames);
#pragma warning restore 618
        }
Esempio n. 14
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Esempio n. 15
0
        public void GetHashCode_Equals()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Equal(new { TemperatureCoefficient.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
Esempio n. 16
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Equal(TemperatureCoefficient.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
Esempio n. 17
0
        public void CompareToThrowsOnNull()
        {
            TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1);

            Assert.Throws <ArgumentNullException>(() => percentagebykelvin.CompareTo(null));
        }
Esempio n. 18
0
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TemperatureCoefficientUnit)));
        }
Esempio n. 19
0
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Equal(QuantityType.TemperatureCoefficient, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
Esempio n. 20
0
        public void Convert_ToString_EqualsToString()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
Esempio n. 21
0
        public void EqualsReturnsFalseOnNull()
        {
            TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1);

            Assert.False(percentagebykelvin.Equals(null));
        }
Esempio n. 22
0
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
Esempio n. 23
0
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
Esempio n. 24
0
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
Esempio n. 25
0
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
Esempio n. 26
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = TemperatureCoefficient.FromPercentageByKelvins(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(TemperatureCoefficient.FromPercentageByKelvins(1), -1, ComparisonType.Relative));
        }
Esempio n. 27
0
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(value);

            Assert.Equal(TemperatureCoefficient.FromPercentageByKelvins(-value), -quantity);
        }
Esempio n. 28
0
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
Esempio n. 29
0
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
Esempio n. 30
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1);

            Assert.False(percentagebykelvin.Equals(new object()));
        }