示例#1
0
        public void AppPluginsComposed_FromOnlyOtherAppPluginTypesOnly()
        {
            ContainerFixture.Test(fixture =>
            {
                fixture.Arrange.Container(c =>
                {
                    var hostPlugin = new MockHostPlugin();
                    hostPlugin.AddPluginType <MockTypeOneBasedOnKnownType>();

                    var corePlugin = new MockCorePlugin();
                    corePlugin.AddPluginType <MockTypeThreeBasedOnKnownType>();

                    var corePlugin2 = new MockCorePlugin();
                    corePlugin2.AddPluginType <MockTypeTwoBasedOnKnownType>();

                    var appPlugin = new MockApplicationPlugin();
                    appPlugin.AddModule <MockComposedModule>();

                    c.RegisterPlugins(hostPlugin, corePlugin, corePlugin2, appPlugin);
                })
                .Assert.PluginModule <MockComposedModule>(m =>
                {
                    m.ImportedTypes.Should().NotBeNull();
                    m.ImportedTypes.Should().HaveCount(1);
                    m.ImportedTypes.OfType <MockTypeOneBasedOnKnownType>().Should().HaveCount(1);
                });
            });
        }
示例#2
0
        public void WhenAppContainerStarted_EachPluginModuleStarted()
        {
            ContainerFixture.Test(fixture =>
            {
                fixture.Arrange.Container(c =>
                {
                    var hostPlugin = new MockHostPlugin();
                    hostPlugin.AddModule <MockPluginOneModule>();

                    var corePlugin = new MockCorePlugin();
                    corePlugin.AddModule <MockPluginTwoModule>();

                    c.RegisterPlugins(hostPlugin, corePlugin);
                })
                .Act.OnApplication(ca =>
                {
                    ca.Start();
                })
                .Assert.CompositeAppBuilder(ca =>
                {
                    ca.AllModules.OfType <MockPluginModule>()
                    .All(m => m.IsStarted).Should().BeTrue();
                });
            });
        }
示例#3
0
        public void CorePluginsComposed_FromAllOtherPluginTypes()
        {
            ContainerFixture.Test(fixture =>
            {
                fixture.Arrange.Container(c =>
                {
                    var hostPlugin = new MockHostPlugin();
                    hostPlugin.AddPluginType <MockTypeOneBasedOnKnownType>();

                    var appPlugin = new MockApplicationPlugin();
                    appPlugin.AddPluginType <MockTypeTwoBasedOnKnownType>();

                    var corePlugin = new MockCorePlugin();
                    corePlugin.AddPluginType <MockTypeThreeBasedOnKnownType>();

                    c.RegisterPlugins(hostPlugin, appPlugin, corePlugin);

                    // This core plug-in contains a module that is composed
                    // from types contained within the above plug-ins.
                    var composedPlugin = new MockCorePlugin();
                    composedPlugin.AddModule <MockComposedModule>();

                    c.RegisterPlugins(composedPlugin);
                })
                .Assert.PluginModule <MockComposedModule>(m =>
                {
                    m.ImportedTypes.Should().NotBeNull();
                    m.ImportedTypes.Should().HaveCount(3);
                    m.ImportedTypes.OfType <MockTypeOneBasedOnKnownType>().Should().HaveCount(1);
                    m.ImportedTypes.OfType <MockTypeTwoBasedOnKnownType>().Should().HaveCount(1);
                    m.ImportedTypes.OfType <MockTypeThreeBasedOnKnownType>().Should().HaveCount(1);
                });
            });
        }
示例#4
0
        public void ModulesHavingKnownTypeProperties_WillBePopulated()
        {
            ContainerFixture.Test(fixture =>
            {
                fixture.Arrange.Container(c =>
                {
                    // Plug-in type based on the type in the core plug-in.
                    var hostPlugin = new MockHostPlugin();
                    hostPlugin.AddPluginType <MockTypeOneBasedOnKnownType>();

                    // Core plug-in containing a module that is composed from type
                    // instances declared within another plug-in.
                    var corePlugin = new MockCorePlugin();
                    corePlugin.AddModule <MockComposedModule>();

                    c.RegisterPlugins(hostPlugin, corePlugin);
                })
                .Assert.PluginModule <MockComposedModule>(m =>
                {
                    m.ImportedTypes.Should().NotBeNull();
                    m.ImportedTypes.Should().HaveCount(1);
                    m.ImportedTypes.First().Should().BeOfType <MockTypeOneBasedOnKnownType>();
                });
            });
        }
示例#5
0
        public static CompositeContainer WithRabbitMqHost(this CompositeContainer container,
                                                          params Type[] hostTypes)
        {
            var hostPlugin = new MockHostPlugin();

            hostPlugin.AddModule <HostModule>();
            hostPlugin.AddPluginType(hostTypes);

            var corePlugin = new MockCorePlugin();

            corePlugin.AddPluginType <BusSettings>();
            corePlugin.AddModule <MockBusModule>();
            corePlugin.AddModule <MockPublisherModule>();
            corePlugin.AddModule <MockSubscriberModule>();

            container.RegisterPlugin <MessagingPlugin>();
            container.RegisterPlugins(corePlugin);
            container.RegisterPlugins(hostPlugin);

            return(container);
        }
        public void PluginIdsValues_MustBeUnique()
        {
            ContainerFixture.Test(fixture =>
            {
                fixture.Arrange.Container(c =>
                {
                    var hostPlugin = new MockHostPlugin();
                    var corePlugin = new MockCorePlugin();

                    hostPlugin.SetPluginId("1");
                    corePlugin.SetPluginId("1");

                    c.RegisterPlugins(hostPlugin, corePlugin);
                })
                .Act.ComposeContainer()
                .Assert.Exception <ContainerException>(ex =>
                {
                    ex.Message.Should().Contain("Plug-in identity values must be unique.");
                });
            });
        }
        public void PluginIdsValues_MustBeUnique()
        {
            ContainerSetup
            .Arrange((TestTypeResolver config) =>
            {
                var appHostPlugin = new MockAppHostPlugin {
                    PluginId = "1"
                };
                var corePlugin = new MockCorePlugin {
                    PluginId = "1"
                };

                config.AddPlugin(appHostPlugin, corePlugin);
            })
            .Test(
                c => c.Build(),
                (c, e) =>
            {
                e.Should().NotBeNull();
                e.Should().BeOfType <ContainerException>();
            });
        }
        public void PluginCanHave_MultipleModules()
        {
            ContainerFixture.Test(fixture =>
            {
                fixture.Arrange.Container(c =>
                {
                    c.RegisterPlugin <MockHostPlugin>();

                    var testPlugin = new MockCorePlugin();
                    testPlugin.AddModule <MockPluginTwoModule>();
                    testPlugin.AddModule <MockPluginThreeModule>();

                    c.RegisterPlugins(testPlugin);
                })
                .Assert.CompositeAppBuilder(ca =>
                {
                    var pluginModules = ca.CorePlugins.First().Modules.ToArray();
                    pluginModules.Should().HaveCount(2);
                    pluginModules.OfType <MockPluginTwoModule>().Should().HaveCount(1);
                    pluginModules.OfType <MockPluginThreeModule>().Should().HaveCount(1);
                });
            });
        }