Пример #1
0
        public void BinarySerializer_Serialize_GivenNullInput_ShouldReturnNull()
        {
            var binarySerializer = new BinarySerializer();
            var result = binarySerializer.Serialize(null);

            Assert.IsNull(result);
        }
Пример #2
0
        public void BinarySerializer_Serialize_GivenValidReferenceTypeInput_ShouldReturnBytes()
        {
            var binarySerializer = new BinarySerializer();
            var input = "test";
            var result = binarySerializer.Serialize(input);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Length > 0);
        }
Пример #3
0
        public void BinarySerializer_Deserialize_GivenValidReferenceType_ShouldReturnReferenceType()
        {
            var binarySerializer = new BinarySerializer();
            var input = "test";
            var serialized = binarySerializer.Serialize(input);

            var deserialized = binarySerializer.Deserialize<string>(serialized);

            Assert.IsNotNull(deserialized);
            Assert.AreEqual("test", deserialized);
        }
Пример #4
0
        public void BinarySerializer_Deserialize_GivenValidValueType_ShouldReturnValueType()
        {
            var binarySerializer = new BinarySerializer();
            var input = 123;
            var serialized = binarySerializer.Serialize(input);

            var deserialized = binarySerializer.Deserialize<int>(serialized);

            Assert.IsNotNull(deserialized);
            Assert.AreEqual(123, deserialized);
        }
Пример #5
0
        public void BinarySerializer_Serialize_Deserialize_ShouldReturnOriginalResult()
        {
            var binarySerializer = new BinarySerializer();
            var input = "test";
            var serializedResult = binarySerializer.Serialize(input);

            Assert.IsNotNull(serializedResult);

            var deserializedResult = binarySerializer.Deserialize(serializedResult);

            Assert.IsNotNull(deserializedResult);

            var resultString = deserializedResult as string;

            Assert.IsNotNull(resultString);
            Assert.AreEqual("test", resultString);
        }