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); }
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); }