Esempio n. 1
0
        public void SetUp()
        {
            var serializableType   = ReflectionObjectMother.GetSomeSerializableType();
            var formatterConverter = new FormatterConverter();

            _info    = new SerializationInfo(serializableType, formatterConverter);
            _context = new StreamingContext((StreamingContextStates)7);

            _pipelineRegistryStub = MockRepository.GenerateStub <IPipelineRegistry>();
            Assert.That(PipelineRegistry.HasInstanceProvider, Is.False);
            PipelineRegistry.SetInstanceProvider(() => _pipelineRegistryStub);

            _deserializationMethodInvokerMock = MockRepository.GenerateMock <IDeserializationMethodInvoker>();
            _createRealObjectAssertions       = (instance, info, ctx, typeName) => { throw new Exception("Setup assertions and return real object."); };

            // Use testable class instead of partial mock, because RhinoMocks chokes on non-virtual ISerializable.GetObjectData.
            _objectDeserializationProxyBase = new TestableObjectDeserializationProxyBase(
                _info,
                _context,
                (instance, info, ctx, typeName) => _createRealObjectAssertions(instance, info, ctx, typeName));

            PrivateInvoke.SetNonPublicField(_objectDeserializationProxyBase, "_deserializationMethodInvoker", _deserializationMethodInvokerMock);
        }