Exemplo n.º 1
0
        private static object DeserializeInstance(Func <IParticipant>[] participantProviders, byte[] serializedData)
        {
            // Register a factory for deserialization in current (new) app domain.

            Assert.That(PipelineRegistry.HasInstanceProvider, Is.False);
            var defaultPipelineMock = MockRepository.GenerateStrictMock <IPipeline>();

            defaultPipelineMock.Stub(_ => _.ParticipantConfigurationID).Return("Mock Default Pipeline");
            IPipelineRegistry pipelineRegistry = new DefaultPipelineRegistry(defaultPipelineMock);

            PipelineRegistry.SetInstanceProvider(() => pipelineRegistry);

            var participants = participantProviders.Select(pp => pp()).Concat(new[] { new ModifyingParticipant() });
            // Avoid no-modification optimization.
            var pipeline = new DefaultPipelineFactory().Create(c_participantConfigurationID, participants.ToArray());

            pipelineRegistry.Register(pipeline);

            try
            {
                return(Serializer.Deserialize(serializedData));
            }
            finally
            {
                PipelineRegistryTestHelper.ResetPipelineRegistry();
            }
        }
Exemplo n.º 2
0
        public void RegisterAndGet()
        {
            _registry.Register(_somePipeline);

            Assert.That(_registry.Get("some id"), Is.SameAs(_somePipeline));
        }