Exemple #1
0
        public static void Test_DateTime_Deserializes()
        {
            //arrange
            PackedDateTimeSerializerStrategyDecorator serializer = new PackedDateTimeSerializerStrategyDecorator(new GenericTypePrimitiveSharedBufferSerializerStrategy <int>());
            DefaultStreamWriterStrategy writer = new DefaultStreamWriterStrategy();
            DateTime testValue = DateTime.Now;

            //act
            serializer.Write(testValue, writer);
            byte[]   bytes = writer.GetBytes();
            DateTime deserializedInstance = serializer.Read(new DefaultStreamReaderStrategy(bytes));

            //assert
            Assert.NotNull(bytes);
        }
Exemple #2
0
        public static void Test_DateTime_Against_WoWPacketParserTest()
        {
            //arrange
            PackedDateTimeSerializerStrategyDecorator serializer = new PackedDateTimeSerializerStrategyDecorator(new GenericTypePrimitiveSharedBufferSerializerStrategy <int>());
            DefaultStreamWriterStrategy writer = new DefaultStreamWriterStrategy();

            new GenericTypePrimitiveSharedBufferSerializerStrategy <int>().Write(168938967, writer);

            DateTime dateTime = serializer.Read(new DefaultStreamReaderStrategy(writer.GetBytes()));


            //Assert
            Assert.AreEqual(23, dateTime.Minute);
            Assert.AreEqual(23, dateTime.Hour);
            Assert.AreEqual(8, dateTime.Day);
            Assert.AreEqual(2010, dateTime.Year);
            Assert.AreEqual(2, dateTime.Month);
        }
Exemple #3
0
        public static void Test_DateTime_Deserializes_To_Correct_DateTime()
        {
            //arrange
            PackedDateTimeSerializerStrategyDecorator serializer = new PackedDateTimeSerializerStrategyDecorator(new GenericTypePrimitiveSharedBufferSerializerStrategy <int>());
            DefaultStreamWriterStrategy writer = new DefaultStreamWriterStrategy();
            DateTime testValue = DateTime.Now;


            //act
            serializer.Write(testValue, writer);
            byte[]   bytes = writer.GetBytes();
            DateTime deserializedInstance = serializer.Read(new DefaultStreamReaderStrategy(bytes));

            //assert
            Assert.NotNull(bytes);
            Assert.True(deserializedInstance != DateTime.MinValue);

            //Check values
            Assert.AreEqual(testValue.Minute, deserializedInstance.Minute);
            Assert.AreEqual(testValue.Day, deserializedInstance.Day);
            Assert.AreEqual(testValue.Year, deserializedInstance.Year);
            Assert.AreEqual(testValue.Month, deserializedInstance.Month);
        }