Esempio n. 1
0
        public void Build_SetDegreeOfParallelism_LessThanOne_ThrowsArgumentOutOfRangeException()
        {
            var builder = PipelineSettings.New();

            Assert.That(
                () => builder.SetDegreeOfParallelism(0),
                Throws.TypeOf <ArgumentOutOfRangeException>()
                .With.ArgumentOutOfRangeExceptionMessageEqualTo("The degree of parallelism must be greater than 0.", "value", 0));
        }
Esempio n. 2
0
        public void Build_SetDegreeOfParallelism_LessThanOne_ThrowsArgumentOutOfRangeException()
        {
            var builder = PipelineSettings.New();

            Assert.That(
                () => builder.SetDegreeOfParallelism(0),
                Throws.TypeOf <ArgumentOutOfRangeException>()
                .With.Message.EqualTo("The degree of parallelism must be greater than 0.\r\nParameter name: value\r\nActual value was 0."));
        }
 public PipelineSettings GetSettings()
 {
     return(PipelineSettings
            .New()
            .SetForceStrongNaming(ForceStrongNaming)
            .SetKeyFilePath(KeyFilePath)
            .SetEnableSerializationWithoutAssemblySaving(EnableSerializationWithoutAssemblySaving)
            .Build());
 }
        protected override IPipeline CreatePipelineForSerialization(params Func <IParticipant>[] participantProviders)
        {
            _participantProviders = participantProviders;

            var participants = _participantProviders.Select(pp => pp()).ToArray();
            var settings     = PipelineSettings.New().SetEnableSerializationWithoutAssemblySaving(true).Build();

            return(CreatePipelineWithIntegrationTestAssemblyLocation(c_participantConfigurationID, settings, participants));
        }
Esempio n. 5
0
        public void SetUp()
        {
            var assemblyTrackingPipelineFactory = new AssemblyTrackingPipelineFactory();
            var settings     = PipelineSettings.New().SetEnableSerializationWithoutAssemblySaving(true).Build();
            var participants = new IParticipant[] { new MixinParticipant() };

            s_pipeline = assemblyTrackingPipelineFactory.Create("re-mix-tests", settings, participants);
            s_assemblyTrackingCodeManager = assemblyTrackingPipelineFactory.AssemblyTrackingCodeManager;
        }
Esempio n. 6
0
        private IPipeline CreateObjectFactoryForStrongNaming(IParticipant participant, bool forceStrongNaming, string keyFilePath = null)
        {
            var settings = PipelineSettings
                           .New()
                           .SetForceStrongNaming(forceStrongNaming)
                           .SetKeyFilePath(keyFilePath)
                           .Build();

            return(CreatePipelineWithIntegrationTestAssemblyLocation("StrongNamingTest", settings, participant));
        }
Esempio n. 7
0
        protected override IPipeline CreatePipelineForSerialization(params Func <IParticipant>[] participantProviders)
        {
            var settings = (PipelineSettings.New())
                           .SetAssemblyDirectory(AppDomain.CurrentDomain.BaseDirectory)
                           .Build();

            var participants = participantProviders.Select(pp => pp());

            var pipeline = CreatePipelineExactAssemblyLocation("standard", settings, participants.ToArray());

            return(pipeline);
        }
Esempio n. 8
0
        public void SetUp()
        {
            _settings              = PipelineSettings.New().Build();
            _codeManagerMock       = new Mock <ICodeManager> (MockBehavior.Strict);
            _reflectionServiceMock = new Mock <IReflectionService> (MockBehavior.Strict);
            _typeAssemblerMock     = new Mock <ITypeAssembler> (MockBehavior.Strict);

            _pipeline = new Pipeline(_settings, _codeManagerMock.Object, _reflectionServiceMock.Object, _typeAssemblerMock.Object);

            _requestedType = ReflectionObjectMother.GetSomeType();
            _typeID        = AssembledTypeIDObjectMother.Create();
        }
Esempio n. 9
0
        public void SetUp()
        {
            _settings              = PipelineSettings.New().Build();
            _codeManagerMock       = MockRepository.GenerateStrictMock <ICodeManager>();
            _reflectionServiceMock = MockRepository.GenerateStrictMock <IReflectionService>();
            _typeAssemblerMock     = MockRepository.GenerateStrictMock <ITypeAssembler>();

            _pipeline = new Pipeline(_settings, _codeManagerMock, _reflectionServiceMock, _typeAssemblerMock);

            _requestedType = ReflectionObjectMother.GetSomeType();
            _typeID        = AssembledTypeIDObjectMother.Create();
        }
Esempio n. 10
0
        public void CustomNamePatternWithoutCounter_OverwritesPreviousAssembly()
        {
            var settings = PipelineSettings.New()
                           .SetAssemblyNamePattern("xxx")
                           .Build();

            var pipeline = CreatePipelineExactAssemblyLocation("standard", settings, CreateParticipant());

            var assemblyPath1 = RequestTypeAndFlush(pipeline, typeof(RequestedType));
            var assemblyPath2 = RequestTypeAndFlush(pipeline, typeof(OtherRequestedType));

            Assert.That(assemblyPath1, Is.EqualTo(assemblyPath2));
        }
Esempio n. 11
0
        public void CustomNamePatternIncludingCounter_ProducesUniqueAssemblyNames()
        {
            var settings = PipelineSettings.New()
                           .SetAssemblyNamePattern("xxx_{counter}")
                           .Build();

            var pipeline = CreatePipelineExactAssemblyLocation("standard", settings, CreateParticipant());

            var assemblyPath1 = RequestTypeAndFlush(pipeline, typeof(RequestedType));
            var assemblyPath2 = RequestTypeAndFlush(pipeline, typeof(OtherRequestedType));

            Assert.That(assemblyPath1, Is.Not.EqualTo(assemblyPath2));
        }
Esempio n. 12
0
        public void CustomNamePatternAndDirectory()
        {
            var directory = Path.GetTempPath();
            var settings  = PipelineSettings.New()
                            .SetAssemblyDirectory(directory)
                            .SetAssemblyNamePattern("Abc")
                            .Build();

            Assert.That(settings.AssemblyDirectory, Is.EqualTo(directory));
            Assert.That(settings.AssemblyNamePattern, Is.EqualTo("Abc"));

            var pipeline = CreatePipelineExactAssemblyLocation("standard", settings, CreateParticipant());

            // The assembly will be saved in a directory that lacks the needed references for peverify.
            var path = RequestTypeAndFlush(pipeline, skipPeVerification: true);

            Assert.That(path, Is.EqualTo(Path.Combine(directory, "Abc.dll")));
            Assert.That(File.Exists(path), Is.True);
        }
        public override void SetUp()
        {
            base.SetUp();

            _blockingMutexA = new Mutex(initiallyOwned: true);
            _blockingMutexB = new Mutex(initiallyOwned: true);

            var blockingParticipant = CreateParticipant(
                participateAction: (id, ctx) =>
            {
                if (ctx.RequestedType == typeof(DomainTypeCausingParticipantToBlockMutexA))
                {
                    _blockingMutexA.WaitOne();
                }

                if (ctx.RequestedType == typeof(DomainTypeCausingParticipantToBlockMutexB))
                {
                    _blockingMutexB.WaitOne();
                }
            },
                additionalTypeFunc: (additionalTypeID, ctx) =>
            {
                var baseType = Type.GetType((string)additionalTypeID, true, false);
                return(ctx.CreateAddtionalProxyType(additionalTypeID, baseType));
            },
                getAdditionalTypeIDFunc: additionalType =>
            {
                if (additionalType.BaseType == typeof(DomainTypeCausingParticipantToBlockMutexA))
                {
                    _blockingMutexA.WaitOne();
                }

                return(additionalType.BaseType.FullName);
            });

            var settings = PipelineSettings.New().SetDegreeOfParallelism(2).Build();

            _pipeline = CreatePipelineWithIntegrationTestAssemblyLocation("ConcurrencyTest_WithMultipleGenerationThreads", settings, blockingParticipant);

            // Disable saving - it would deadlock with a failing test while threads are blocked.
            SkipSavingAndPeVerification();
        }
Esempio n. 14
0
        public override void SetUp()
        {
            base.SetUp();

            _blockingMutex = new Mutex(initiallyOwned: true);

            var blockingParticipant = CreateParticipant(
                (id, ctx) =>
            {
                if (ctx.RequestedType == typeof(DomainTypeCausingParticipantToBlock))
                {
                    _blockingMutex.WaitOne();
                }
            },
                additionalTypeFunc: (additionalTypeID, ctx) => typeof(OtherDomainType));

            var settings = PipelineSettings.New().SetDegreeOfParallelism(1).Build();

            _pipeline = CreatePipelineWithIntegrationTestAssemblyLocation("ConcurrencyTest_WithSingleGenerationThread", settings, blockingParticipant);

            // Disable saving - it would deadlock with a failing test while threads are blocked.
            SkipSavingAndPeVerification();
        }
Esempio n. 15
0
        public void Build_SetAssemblyDirectory()
        {
            var settings = PipelineSettings.New().SetAssemblyDirectory("set_value").Build();

            Assert.That(settings.AssemblyDirectory, Is.EqualTo("set_value"));
        }
Esempio n. 16
0
        public void Build_SetEnableSerializationWithoutAssemblySaving()
        {
            var settings = PipelineSettings.New().SetEnableSerializationWithoutAssemblySaving(true).Build();

            Assert.That(settings.EnableSerializationWithoutAssemblySaving, Is.True);
        }
Esempio n. 17
0
        public void Build_SetKeyFilePath()
        {
            var settings = PipelineSettings.New().SetKeyFilePath("set_value").Build();

            Assert.That(settings.KeyFilePath, Is.EqualTo("set_value"));
        }
Esempio n. 18
0
        public void Build_SetForceStrongNaming()
        {
            var settings = PipelineSettings.New().SetForceStrongNaming(true).Build();

            Assert.That(settings.ForceStrongNaming, Is.True);
        }
Esempio n. 19
0
        public void Build_SetDegreeOfParallelism()
        {
            var settings = PipelineSettings.New().SetDegreeOfParallelism(3).Build();

            Assert.That(settings.DegreeOfParallelism, Is.EqualTo(3));
        }
Esempio n. 20
0
        public void AssemblyNamePatternBuild_SetKeyFilePath()
        {
            var settings = PipelineSettings.New().SetAssemblyNamePattern("set_value").Build();

            Assert.That(settings.AssemblyNamePattern, Is.EqualTo("set_value"));
        }