Пример #1
0
        public void SerializeToStream_WhenUsingStream_ExpectDeserializeCorrect()
        {
            // Arrange
            var jsonSerializer = new Logic.JsonSerializer(false);

            var testEntity = TestHelper.GetDefaultTestEntity;

            // Act
            var stopwatch         = Stopwatch.StartNew();
            var serializeToStream = jsonSerializer.SerializeToStream(testEntity);

            Console.WriteLine($"Length: {serializeToStream.Length}");

            var deserializeFromByteArray = jsonSerializer.DeserializeFromStream <TestEntity>(serializeToStream);

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            deserializeFromByteArray.AssertEqualsDefault();
        }
Пример #2
0
        public void SerializeToByteArray_WhenUsingByteArrayWithType_ExpectDeserializeCorrect()
        {
            // Arrange
            var jsonSerializer = new Logic.JsonSerializer(false);

            var testEntity = TestHelper.GetDefaultTestEntity;

            // Act
            var stopwatch            = Stopwatch.StartNew();
            var serializeToByteArray = jsonSerializer.SerializeToByteArray(testEntity, typeof(TestEntity));

            Console.WriteLine(JsonConvert.SerializeObject(serializeToByteArray));

            var deserializeFromByteArray = jsonSerializer.DeserializeFromByteArray(serializeToByteArray, typeof(TestEntity));

            stopwatch.Stop();

            // Assert
            this.WriteTimeElapsed(stopwatch);

            deserializeFromByteArray.AssertEqualsDefault();
        }