Example #1
0
        public void ToUInt16_UInt16OverloadValueAndLengthInstanceIsNull_ThrowsArgumentNullException()
        {
            IBitCharger instance = null;

            Int32 offset = 42;

            Assert.That(() => instance.ToUInt16(offset), Throws.ArgumentNullException);
        }
Example #2
0
        public void ToUInt16_OnlyValue_ResultAsExpected()
        {
            IBitCharger instance = this.CreateInstance();

            UInt16 expected = 4711; // LE: 0x6712 => 01100111 00010010

            Byte[] array = new Byte[] { 0x67, 0x12 };

            instance.SetBytes(array);

            Assert.That(instance.ToUInt16(), Is.EqualTo(expected));
        }
Example #3
0
        public void ToUInt16_ValueAndOffset_ResultAsExpected()
        {
            IBitCharger instance = this.CreateInstance();

            UInt16 expected = 4711; // LE: 0x6712 => 01100111 00010010
            Int32  offset   = 2;

            Byte[] array = new Byte[] { 0x67, 0x12 };

            instance.SetBytes(array, offset);

            Assert.That(instance.ToUInt16(offset), Is.EqualTo(expected));
        }
Example #4
0
 /// <summary>
 /// Gets all bytes from the charger and converts them into
 /// <see cref="UInt16"/>.
 /// </summary>
 /// <remarks>
 /// This method gets all bytes from the charger and converts
 /// them into <see cref="UInt16"/>.
 /// </remarks>
 /// <param name="charger">
 /// An instance of <see cref="IBitCharger"/> to set the bits
 /// </param>
 /// <returns>
 /// A value of type <see cref="UInt16"/> representing all applied
 /// bits.
 /// </returns>
 public static UInt16 ToUInt16(this IBitCharger charger)
 {
     return(charger.ToUInt16(0));
 }
Example #5
0
        public void ToUInt16_UInt16OverloadOnlyValueInstanceIsNull_ThrowsArgumentNullException()
        {
            IBitCharger instance = null;

            Assert.That(() => instance.ToUInt16(), Throws.ArgumentNullException);
        }