Example #1
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();
                });
            });
        }
Example #2
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);
                });
            });
        }
Example #3
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>();
                });
            });
        }
Example #4
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 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);
                });
            });
        }