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)); }
public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { var quantity = new TemperatureCoefficient(); Assert.Equal(0, quantity.Value); Assert.Equal(TemperatureCoefficientUnit.PercentageByKelvin, quantity.Unit); }
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()); }
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)); }
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); }
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)); }
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); }
/// <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); }
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); }
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); }
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 }
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 }
public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }
public void GetHashCode_Equals() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(new { TemperatureCoefficient.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode()); }
public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(TemperatureCoefficient.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); }
public void CompareToThrowsOnNull() { TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1); Assert.Throws <ArgumentNullException>(() => percentagebykelvin.CompareTo(null)); }
public void Convert_ChangeType_UnitType_EqualsUnit() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TemperatureCoefficientUnit))); }
public void Convert_ChangeType_QuantityType_EqualsQuantityType() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(QuantityType.TemperatureCoefficient, Convert.ChangeType(quantity, typeof(QuantityType))); }
public void Convert_ToString_EqualsToString() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); }
public void EqualsReturnsFalseOnNull() { TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1); Assert.False(percentagebykelvin.Equals(null)); }
public void Convert_ToDecimal_EqualsValueAsSameType() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); }
public void Convert_ToSingle_EqualsValueAsSameType() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }
public void Convert_ToDateTime_ThrowsInvalidCastException() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity)); }
public void ToString_NullProvider_EqualsCurrentUICulture() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); }
public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { var v = TemperatureCoefficient.FromPercentageByKelvins(1); Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(TemperatureCoefficient.FromPercentageByKelvins(1), -1, ComparisonType.Relative)); }
public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { var quantity = TemperatureCoefficient.FromPercentageByKelvins(value); Assert.Equal(TemperatureCoefficient.FromPercentageByKelvins(-value), -quantity); }
public void Convert_ToUInt64_EqualsValueAsSameType() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }
public void ToString_NullArgs_ThrowsArgumentNullException() { var quantity = TemperatureCoefficient.FromPercentageByKelvins(1.0); Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null)); }
public void EqualsReturnsFalseOnTypeMismatch() { TemperatureCoefficient percentagebykelvin = TemperatureCoefficient.FromPercentageByKelvins(1); Assert.False(percentagebykelvin.Equals(new object())); }