Ejemplo n.º 1
0
        public void BinarySerializer_Serialize_GivenNullInput_ShouldReturnNull()
        {
            var binarySerializer = new BinarySerializer();
            var result = binarySerializer.Serialize(null);

            Assert.IsNull(result);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }