public void SerializeValueOutOfRangeException()
        {
            string message   = "Serialized ValueOutOfRangeException";
            var    exception = new ValueOutOfRangeException(message);

            var deserializedException = ExceptionSerialiseHelper(exception, typeof(ValueOutOfRangeException)) as ValueOutOfRangeException;

            // ValueOutOfRangeException appends 'out of range' to the end of the message
            Assert.That(deserializedException.Message, Is.EqualTo($"{message} out of range"), "should have expected message");
        }
 // This method charge the engine battery, only if it is less than MaxCap.
 public void Charge(float i_NumHoursCharged)
 {
     if (this.MaxCapacity >= this.CurrAmount + i_NumHoursCharged)
     {
         this.CurrAmount += i_NumHoursCharged;
     }
     else
     {
         // Charged Amount is too big.
         var voore = new ValueOutOfRangeException(0, this.MaxCapacity);
         voore.Source = this.GetType().Name;
         throw voore;
     }
 }
Exemplo n.º 3
0
 public void Inflating(float i_AirToAdd)
 {
     if (i_AirToAdd == MaxAirPressure)
     {
         CurrentAirPressure = i_AirToAdd;
     }
     else if (CurrentAirPressure + i_AirToAdd <= MaxAirPressure)
     {
         CurrentAirPressure += i_AirToAdd;
     }
     else
     {
         ValueOutOfRangeException i_ValueOutOfRangeException = new ValueOutOfRangeException(MaxAirPressure, 0);
         throw i_ValueOutOfRangeException;
     }
 }
Exemplo n.º 4
0
 public Tire(string i_ManufacturerName, float i_MaxAirPressure)
 {
     r_ManufacturerName = i_ManufacturerName;
     r_MaxAirPressure   = i_MaxAirPressure;
     r_CheckRange       = new ValueOutOfRangeException(0, i_MaxAirPressure);
 }
Exemplo n.º 5
0
 protected EnergyStorage(float i_MaxCapacity)
 {
     r_MaxCapacity = i_MaxCapacity;
     r_CheckRange  = new ValueOutOfRangeException(0, i_MaxCapacity);
 }