Exemplo 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));
        }
Exemplo n.º 2
0
        public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit()
        {
            var quantity = new TemperatureCoefficient();

            Assert.Equal(0, quantity.Value);
            Assert.Equal(TemperatureCoefficientUnit.PercentageByKelvin, quantity.Unit);
        }
Exemplo 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());
        }
Exemplo 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));
        }
Exemplo 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);
        }
Exemplo 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));
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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
        }
Exemplo 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
        }
Exemplo n.º 14
0
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
Exemplo 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());
        }
Exemplo n.º 16
0
        public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0);

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

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

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

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

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

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

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

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

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
Exemplo 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"));
        }
Exemplo n.º 26
0
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = TemperatureCoefficient.FromPercentageByKelvins(1);

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

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

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

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

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