예제 #1
0
        public void GetBytes_GuidProvided_BytesReturned()
        {
            TestConverter converter = new TestConverter();

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

            Assert.AreEqual(16, bytes.Length);
        }
예제 #2
0
        public void GetBytes_EnumProvided_BytesReturned()
        {
            TestConverter converter = new TestConverter();

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

            Assert.AreEqual(sizeof(int), bytes.Length);
        }
예제 #3
0
        public void GetBytes_StringProvided_BytesReturned()
        {
            TestConverter converter = new TestConverter();

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

            Assert.IsTrue(bytes.Length > 0);
        }
예제 #4
0
        public void IsValueType_ReferenceTypeProvided_FalseReturned()
        {
            TestConverter converter = new TestConverter();

            bool result = converter.TestIsValueType(typeof(IList));

            Assert.IsFalse(result);
        }
예제 #5
0
        public void GetBytes_LongProvided_BytesReturned()
        {
            TestConverter converter = new TestConverter();

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

            Assert.AreEqual(sizeof(long), bytes.Length);
        }
예제 #6
0
        public void IsValueType_PrimitiveTypeNameProvided_TrueReturned()
        {
            TestConverter converter = new TestConverter();

            bool result = converter.TestIsValueType(typeof(int).AssemblyQualifiedName);

            Assert.IsTrue(result);
        }
예제 #7
0
        public void IsValueType_DateTimeTypeProvided_TrueReturned()
        {
            TestConverter converter = new TestConverter();

            bool result = converter.TestIsValueType(typeof(DateTime));

            Assert.IsTrue(result);
        }
예제 #8
0
        public void IsStringType_PrimitiveTypeProvided_FalseReturned()
        {
            TestConverter converter = new TestConverter();

            bool result = converter.TestIsStringType(typeof(int));

            Assert.IsFalse(result);
        }
예제 #9
0
        public void IsStringType_StringTypeProvided_TrueReturned()
        {
            TestConverter converter = new TestConverter();

            bool result = converter.TestIsStringType(typeof(string));

            Assert.IsTrue(result);
        }
예제 #10
0
        public void GetBytes_UShortProvided_BytesReturned()
        {
            TestConverter converter = new TestConverter();

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

            Assert.AreEqual(sizeof(ushort), bytes.Length);
        }
예제 #11
0
        public void TypeSize_DecimalTypeProvided_SizeReturned()
        {
            TestConverter converter = new TestConverter();

            int result = converter.TestTypeSize(typeof(decimal));

            Assert.AreEqual(sizeof(decimal), result);
        }
예제 #12
0
        public void TypeSize_NullProvided_ZeroReturned()
        {
            TestConverter converter = new TestConverter();

            int result = converter.TestTypeSize(null as Type);

            Assert.AreEqual(0, result);
        }
예제 #13
0
        public void TypeSize_GuidTypeProvided_SizeReturned()
        {
            TestConverter converter = new TestConverter();

            int result = converter.TestTypeSize(typeof(Guid));

            Assert.AreEqual(16, result);
        }
예제 #14
0
        public void TypeSize_UShortTypeProvided_SizeReturned()
        {
            TestConverter converter = new TestConverter();

            int result = converter.TestTypeSize(typeof(ushort));

            Assert.AreEqual(sizeof(ushort), result);
        }
예제 #15
0
        public void TypeSize_DateTimeTypeProvided_SizeReturned()
        {
            TestConverter converter = new TestConverter();

            int result = converter.TestTypeSize(typeof(DateTime));

            Assert.AreEqual(sizeof(long), result);
        }
예제 #16
0
        public void TypeSize_EnumTypeProvided_SizeReturned()
        {
            TestConverter converter = new TestConverter();

            int result = converter.TestTypeSize(typeof(StringComparison));

            Assert.AreEqual(sizeof(int), result);
        }
예제 #17
0
        public void TypeSize_PrimitiveTypeNameProvided_SizeReturned()
        {
            TestConverter converter = new TestConverter();

            int result = converter.TestTypeSize(typeof(int).AssemblyQualifiedName);

            Assert.AreEqual(sizeof(int), result);
        }
예제 #18
0
        public void IsStringType_NullProvided_FalseReturned()
        {
            TestConverter converter = new TestConverter();

            bool result = converter.TestIsStringType(null);

            Assert.IsFalse(result);
        }
예제 #19
0
        public void IsValueType_EnumTypeProvided_TrueReturned()
        {
            TestConverter converter = new TestConverter();

            bool result = converter.TestIsValueType(typeof(StringComparison));

            Assert.IsTrue(result);
        }
예제 #20
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]);
        }
예제 #21
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]);
        }
예제 #22
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);
        }
예제 #23
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);
        }
예제 #24
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);
        }
예제 #25
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);
        }
예제 #26
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);
        }
예제 #27
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);
        }
예제 #28
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);
        }
예제 #29
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);
        }
예제 #30
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);
        }