Ejemplo n.º 1
0
        public void Test_ToDateTime_UseNbo()
        {
            var converter   = new DefaultConverter();
            var theDateTime = new DateTime(1972, 12, 7);

            var bytes    = BitConverter.GetBytes(theDateTime.ToBinary()).Reverse().ToArray();
            var actual   = converter.ToDateTime(bytes, 0, true);
            var expected = new DateTime(1972, 12, 7);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        public void Test_ToDateTime(int year, int month, int day, bool useNbo)
        {
            var converter = new DefaultConverter();

            var value = new DateTime(year, month, day);

            var bytes = BitConverter.GetBytes(value.ToBinary());

            if (useNbo)
            {
                bytes = bytes.Reverse().ToArray();
            }

            var actual = converter.ToDateTime(bytes.AsSpan(), useNbo);

            Assert.Equal(value, actual);
        }