Example #1
0
        public void Test_BitFlagHelperTests_BitOn_byte()
        {
            byte value = 0;
            value =  BitFlagHelper.BitOn(value, 0);

            Assert.Equal(1, value);
        }
Example #2
0
        /// <summary>
        /// Sets the appropriate bits in the GPSModeStore corresponding to the desired pass type
        /// </summary>
        /// <param name="value"></param>
        /// <param name="passType"></param>
        /// <returns></returns>
        public static byte SetPassType(byte value, PassType passType)
        {
            byte result = value;

            switch (passType)
            {
            case PassType.Front: // val 0
                result = BitFlagHelper.BitOff(result, (int)GPSFlagBits.GPSSBit6);
                result = BitFlagHelper.BitOff(result, (int)GPSFlagBits.GPSSBit7);
                break;

            case PassType.Rear: // val 1
                result = BitFlagHelper.BitOn(result, (int)GPSFlagBits.GPSSBit6);
                result = BitFlagHelper.BitOff(result, (int)GPSFlagBits.GPSSBit7);
                break;

            case PassType.Track: // val 2
                result = BitFlagHelper.BitOff(result, (int)GPSFlagBits.GPSSBit6);
                result = BitFlagHelper.BitOn(result, (int)GPSFlagBits.GPSSBit7);
                break;

            case PassType.Wheel: // val 3
                result = BitFlagHelper.BitOn(result, (int)GPSFlagBits.GPSSBit6);
                result = BitFlagHelper.BitOn(result, (int)GPSFlagBits.GPSSBit7);
                break;

            default:
                throw new ArgumentException($"Unknown pass type supplied to SetPassType {passType}", nameof(passType));
            }

            return(result);
        }
Example #3
0
        public void Test_BitFlagHelperTests_BitOff_ushort()
        {
          ushort value = 1;
          value = BitFlagHelper.BitOff(value, 0);

          Assert.Equal(0, value);
        }
Example #4
0
        public void Test_BitFlagHelperTests_BitOn_ushort()
        {
          ushort value = 0;
          value = BitFlagHelper.BitOn(value, 0);

          Assert.Equal(1, value);
        }
Example #5
0
        public void Test_BitFlagHelperTests_BitOff_byte()
        {
            byte value = 1;
            value = BitFlagHelper.BitOff(value, 0);

            Assert.Equal(0, value);
        }
Example #6
0
        public void Test_BitFlagHelperTests_SetBit()
        {
            byte value = 0;

            BitFlagHelper.SetBit(ref value, 0, false);
            Assert.True(BitFlagHelper.IsBitOff(value, 0), "IsBitOff() for 0 bit returned false (it should be true)");

            BitFlagHelper.SetBit(ref value, 0, true);
            Assert.True(BitFlagHelper.IsBitOn(value, 0), "IsBitOn() for 0 bit returned false (it should be true)");
        }
Example #7
0
        public void Test_BitFlagHelperTests_IsBitOn()
        {
            byte value = 1;

            Assert.True(BitFlagHelper.IsBitOn(value, 0), "IsBitOn() for 0 bit returned false (it should be true)");

            byte value2 = 0;

            Assert.False(BitFlagHelper.IsBitOn(value2, 0), "IsBitOn() for 0 bit returned true (it should be false)");
        }