Exemple #1
0
        public static void SetDoseRate(DoseRate doseRate)
        {
            SetUp();

            SM.Instance.Keyboard.Press("R");
            SM.Instance.ServiceConsoleState.Setup.Current = SetupOptions.REP_RATE;
            Thread.Sleep(200);
            switch (doseRate)
            {
            case DoseRate._100: SM.Instance.Keyboard.EnterNumber(1); break;

            case DoseRate._200: SM.Instance.Keyboard.EnterNumber(2); break;

            case DoseRate._300: SM.Instance.Keyboard.EnterNumber(3); break;

            case DoseRate._400: SM.Instance.Keyboard.EnterNumber(4); break;

            case DoseRate._500: SM.Instance.Keyboard.EnterNumber(5); break;

            case DoseRate._600: SM.Instance.Keyboard.EnterNumber(6); break;
            }
            Thread.Sleep(200);
            SM.Instance.MachineState.DoseRate = doseRate;
            SM.Instance.ResetConsoleState();
        }
        public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit()
        {
            var quantity00 = DoseRate.From(1, DoseRateUnit.GrayPerSecond);

            AssertEx.EqualTolerance(1, quantity00.GrayPerSeconds, GrayPerSecondsTolerance);
            Assert.Equal(DoseRateUnit.GrayPerSecond, quantity00.Unit);
        }
        public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit()
        {
            var quantity = new DoseRate();

            Assert.Equal(0, quantity.Value);
            Assert.Equal(DoseRateUnit.GrayPerSecond, quantity.Unit);
        }
        public void Equals_RelativeTolerance_IsImplemented()
        {
            var v = DoseRate.FromGrayPerSeconds(1);

            Assert.True(v.Equals(DoseRate.FromGrayPerSeconds(1), GrayPerSecondsTolerance, ComparisonType.Relative));
            Assert.False(v.Equals(DoseRate.Zero, GrayPerSecondsTolerance, ComparisonType.Relative));
        }
        public void Equals_SameType_IsImplemented()
        {
            var a = DoseRate.FromGrayPerSeconds(1);
            var b = DoseRate.FromGrayPerSeconds(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
        }
        public void CompareToIsImplemented()
        {
            DoseRate graypersecond = DoseRate.FromGrayPerSeconds(1);

            Assert.Equal(0, graypersecond.CompareTo(graypersecond));
            Assert.True(graypersecond.CompareTo(DoseRate.Zero) > 0);
            Assert.True(DoseRate.Zero.CompareTo(graypersecond) < 0);
        }
        public void Equals_QuantityAsObject_IsImplemented()
        {
            object a = DoseRate.FromGrayPerSeconds(1);
            object b = DoseRate.FromGrayPerSeconds(2);

            Assert.True(a.Equals(a));
            Assert.False(a.Equals(b));
            Assert.False(a.Equals((object)null));
        }
        public void ToUnit()
        {
            var graypersecond = DoseRate.FromGrayPerSeconds(1);

            var graypersecondQuantity = graypersecond.ToUnit(DoseRateUnit.GrayPerSecond);

            AssertEx.EqualTolerance(GrayPerSecondsInOneGrayPerSecond, (double)graypersecondQuantity.Value, GrayPerSecondsTolerance);
            Assert.Equal(DoseRateUnit.GrayPerSecond, graypersecondQuantity.Unit);
        }
        public void ArithmeticOperators()
        {
            DoseRate v = DoseRate.FromGrayPerSeconds(1);

            AssertEx.EqualTolerance(-1, -v.GrayPerSeconds, GrayPerSecondsTolerance);
            AssertEx.EqualTolerance(2, (DoseRate.FromGrayPerSeconds(3) - v).GrayPerSeconds, GrayPerSecondsTolerance);
            AssertEx.EqualTolerance(2, (v + v).GrayPerSeconds, GrayPerSecondsTolerance);
            AssertEx.EqualTolerance(10, (v * 10).GrayPerSeconds, GrayPerSecondsTolerance);
            AssertEx.EqualTolerance(10, (10 * v).GrayPerSeconds, GrayPerSecondsTolerance);
            AssertEx.EqualTolerance(2, (DoseRate.FromGrayPerSeconds(10) / 5).GrayPerSeconds, GrayPerSecondsTolerance);
            AssertEx.EqualTolerance(2, DoseRate.FromGrayPerSeconds(10) / DoseRate.FromGrayPerSeconds(5), GrayPerSecondsTolerance);
        }
        public void ComparisonOperators()
        {
            DoseRate oneGrayPerSecond  = DoseRate.FromGrayPerSeconds(1);
            DoseRate twoGrayPerSeconds = DoseRate.FromGrayPerSeconds(2);

            Assert.True(oneGrayPerSecond < twoGrayPerSeconds);
            Assert.True(oneGrayPerSecond <= twoGrayPerSeconds);
            Assert.True(twoGrayPerSeconds > oneGrayPerSecond);
            Assert.True(twoGrayPerSeconds >= oneGrayPerSecond);

            Assert.False(oneGrayPerSecond > twoGrayPerSeconds);
            Assert.False(oneGrayPerSecond >= twoGrayPerSeconds);
            Assert.False(twoGrayPerSeconds < oneGrayPerSecond);
            Assert.False(twoGrayPerSeconds <= oneGrayPerSecond);
        }
        public void EqualityOperators()
        {
            var a = DoseRate.FromGrayPerSeconds(1);
            var b = DoseRate.FromGrayPerSeconds(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 DoseRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity()
        {
            var quantity = new DoseRate(1, DoseRateUnit.GrayPerSecond);

            QuantityInfo <DoseRateUnit> quantityInfo = quantity.QuantityInfo;

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

            var units     = EnumUtils.GetEnumValues <DoseRateUnit>().Except(new[] { DoseRateUnit.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_BaseDimensions_EqualsBaseDimensions()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Equal(DoseRate.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions)));
        }
        public void Convert_ChangeType_QuantityType_EqualsQuantityType()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Equal(QuantityType.DoseRate, Convert.ChangeType(quantity, typeof(QuantityType)));
        }
        public void Convert_ChangeType_UnitType_EqualsUnit()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(DoseRateUnit)));
        }
        public void Convert_ChangeType_SelfType_EqualsSelf()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(DoseRate)));
        }
        public void Convert_ToUInt64_EqualsValueAsSameType()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity));
        }
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            DoseRate graypersecond = DoseRate.FromGrayPerSeconds(1);

            Assert.False(graypersecond.Equals(new object()));
        }
        public void GetHashCode_Equals()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Equal(new { DoseRate.QuantityType, quantity.Value, quantity.Unit }.GetHashCode(), quantity.GetHashCode());
        }
        public void Convert_ToDateTime_ThrowsInvalidCastException()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ToDateTime(quantity));
        }
        public void ToString_NullProvider_EqualsCurrentUICulture()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g"));
        }
        public void ToString_NullArgs_ThrowsArgumentNullException()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Throws <ArgumentNullException>(() => quantity.ToString(null, "g", null));
        }
        public void EqualsReturnsFalseOnNull()
        {
            DoseRate graypersecond = DoseRate.FromGrayPerSeconds(1);

            Assert.False(graypersecond.Equals(null));
        }
        public void Convert_ToSingle_EqualsValueAsSameType()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity));
        }
        public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Throws <InvalidCastException>(() => Convert.ChangeType(quantity, typeof(QuantityFormatter)));
        }
        public void Convert_ToString_EqualsToString()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Equal(quantity.ToString(), Convert.ToString(quantity));
        }
        public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value)
        {
            var quantity = DoseRate.FromGrayPerSeconds(value);

            Assert.Equal(DoseRate.FromGrayPerSeconds(-value), -quantity);
        }
        public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException()
        {
            var v = DoseRate.FromGrayPerSeconds(1);

            Assert.Throws <ArgumentOutOfRangeException>(() => v.Equals(DoseRate.FromGrayPerSeconds(1), -1, ComparisonType.Relative));
        }
        public void Convert_ToDecimal_EqualsValueAsSameType()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity));
        }
        public void Convert_ToInt32_EqualsValueAsSameType()
        {
            var quantity = DoseRate.FromGrayPerSeconds(1.0);

            Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity));
        }