Ejemplo n.º 1
0
        public void GetBytes_EnumProvided_BytesReturned()
        {
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(StringComparison.Ordinal, Endianness.LittleEndian);

            Assert.AreEqual(sizeof(int), bytes.Length);
        }
Ejemplo n.º 2
0
        public void GetBytes_GuidProvided_BytesReturned()
        {
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(Guid.NewGuid(), Endianness.LittleEndian);

            Assert.AreEqual(16, bytes.Length);
        }
Ejemplo n.º 3
0
        public void GetBytes_UShortProvided_BytesReturned()
        {
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes((ushort)5, Endianness.LittleEndian);

            Assert.AreEqual(sizeof(ushort), bytes.Length);
        }
Ejemplo n.º 4
0
        public void GetBytes_StringProvided_BytesReturned()
        {
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes("Test", Endianness.LittleEndian);

            Assert.IsTrue(bytes.Length > 0);
        }
Ejemplo n.º 5
0
        public void GetBytes_LongProvided_BytesReturned()
        {
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(5L, Endianness.LittleEndian);

            Assert.AreEqual(sizeof(long), bytes.Length);
        }
Ejemplo n.º 6
0
        public void GetBytes_BoolProvided_BytesReturned()
        {
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(true, Endianness.LittleEndian);

            Assert.AreEqual(sizeof(bool), bytes.Length);
            Assert.AreEqual(1, bytes[0]);
        }
Ejemplo n.º 7
0
        public void GetBytes_ByteProvided_BytesReturned()
        {
            byte          b         = 1;
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(b, Endianness.LittleEndian);

            Assert.AreEqual(sizeof(byte), bytes.Length);
            Assert.AreEqual(b, bytes[0]);
        }
Ejemplo n.º 8
0
        public void GetValue_ByteBytesProvided_ByteReturned()
        {
            byte          value     = 1;
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            byte result = converter.TestGetValue <byte>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 9
0
        public void GetValue_EnumBytesProvided_EnumReturned()
        {
            StringComparison value     = StringComparison.Ordinal;
            TestConverter    converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            StringComparison result = converter.TestGetValue <StringComparison>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 10
0
        public void GetValue_DateTimeBytesProvided_DateTimeReturned()
        {
            DateTime      value     = DateTime.Now;
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            DateTime result = converter.TestGetValue <DateTime>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 11
0
        public void GetValue_GuidBytesProvided_GuidReturned()
        {
            Guid          value     = Guid.NewGuid();
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            Guid result = converter.TestGetValue <Guid>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 12
0
        public void GetValue_UShortBytesProvided_UShortReturned()
        {
            ushort        value     = 2048;
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            ushort result = converter.TestGetValue <ushort>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 13
0
        public void GetValue_ULongBytesProvided_ULongReturned()
        {
            ulong         value     = ulong.MaxValue - 1;
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            ulong result = converter.TestGetValue <ulong>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 14
0
        public void GetValue_UIntBytesProvided_UIntReturned()
        {
            uint          value     = 512;
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            uint result = converter.TestGetValue <uint>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 15
0
        public void GetValue_FloatBytesProvided_FloatReturned()
        {
            float         value     = 6.5f;
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            float result = converter.TestGetValue <float>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 16
0
        public void GetValue_DoubleBytesProvided_DoubleReturned()
        {
            double        value     = 3.9d;
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            double result = converter.TestGetValue <double>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 17
0
        public void GetValue_CharBytesProvided_CharReturned()
        {
            char          value     = 'a';
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            char result = converter.TestGetValue <char>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 18
0
        public void GetValue_BoolBytesProvided_BoolReturned()
        {
            bool          value     = true;
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            bool result = converter.TestGetValue <bool>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 19
0
        public void GetValue_StringBytesProvided_StringReturned()
        {
            string        value     = "test";
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            string result = converter.TestGetValue <string>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 20
0
        public void GetValue_DecimalBytesProvided_DecimalReturned()
        {
            decimal       value     = 5.4m;
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(value, Endianness.LittleEndian);

            decimal result = converter.TestGetValue <decimal>(bytes, Endianness.LittleEndian);

            Assert.AreEqual(value, result);
        }
Ejemplo n.º 21
0
        public void GetBytes_InvalidTypeProvided_ThrowsNotSupportedException()
        {
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes(new Tuple <int>(1), Endianness.LittleEndian);
        }
Ejemplo n.º 22
0
        public void GetBytes_NullProvided_ThrowsNotSupportedException()
        {
            TestConverter converter = new TestConverter();

            byte[] bytes = converter.TestGetBytes((object)null, Endianness.LittleEndian);
        }