private void SerializeSingleValue_Test <TValue>(TValue value)
        {
            var @object    = new SingleValue <TValue>(value);
            var serializer = BinarySerializer.Create();

            var bytes        = serializer.Serialize(@object);
            var deserialized = serializer.Deserialize(bytes, @object.GetType()) as SingleValue <TValue>;

            Assert.IsNotNull(deserialized);
            Assert.AreEqual(@object.Value, deserialized.Value);
        }
コード例 #2
0
        private Mock <IWriter> SingleValueTest <T>(T value)
        {
            var obj     = new SingleValue <T>(value);
            var factory = new ILSerializerFactory();

            var ctxMock    = new Mock <ISerializationContext>();
            var writerMock = new Mock <IWriter>();

            ctxMock.Setup(c => c.Writer)
            .Returns(writerMock.Object);

            var serializer = factory.Create(obj.GetType(), ctxMock.Object);

            serializer.Serialize(obj, ctxMock.Object);

            return(writerMock);
        }