Example #1
0
        public void LoadPlugins_Find_All_Referenced_Plugins()
        {
            var testAssemblyProvider = new TestAssemblyProvider();
            var testAssembly         = Assembly.GetExecutingAssembly();

            testAssemblyProvider.RegisterTestAssembly(testAssembly);

            //ARRANGE
            var runtimePluginLocator = new RuntimePluginLocator(new RuntimePluginLocationMerger(), new SpecFlowPath(), testAssemblyProvider);

            //ACT
            var plugins = runtimePluginLocator.GetAllRuntimePlugins();

            //ASSERT
            var projectReferences = GetProjectReferencesDlls();
            var allProjectReferenceFoundByPluginLocator = projectReferences.All(pr => plugins.Any(plugin => plugin.Contains(pr)));

            allProjectReferenceFoundByPluginLocator.Should().BeTrue();

            var numberOfGeneratorPlugins = NumberOfGeneratorPluginsReferenced(projectReferences);
            var generatorPluginsFound    = plugins.Where(p => p.Contains("Generator")).ToList();

            generatorPluginsFound.Count.Should().Be(numberOfGeneratorPlugins);

            var numberOfRuntimePlugins = NumberOfRuntimePluginsReferenced(projectReferences);
            var runtimePluginsFound    = plugins.Where(p => !p.Equals(testAssembly.Location)).Except(generatorPluginsFound).ToList();

            runtimePluginsFound.Should().HaveCount(numberOfRuntimePlugins, $"{string.Join(",", runtimePluginsFound)} were found");
        }
        public void LoadPlugins_Find_All_3_Referenced_RuntimePlugins()
        {
            //ARRANGE
            var runtimePluginLocator = new RuntimePluginLocator(new RuntimePluginLocationMerger());

            //ACT
            var plugins = runtimePluginLocator.GetAllRuntimePlugins();

            //ASSERT
            plugins.Count.Should().Be(3);
        }
        public void LoadPlugins_Find_All_5_Referenced_RuntimePlugins()
        {
            //ARRANGE
            var runtimePluginLocator = new RuntimePluginLocator(new RuntimePluginLocationMerger(), new SpecFlowPath());

            //ACT
            var plugins = runtimePluginLocator.GetAllRuntimePlugins();

            //ASSERT
            plugins.Count.Should().Be(5, $"{string.Join(",", plugins)} were found");
        }
Example #4
0
        public void LoadPlugins_Find_TestAssembly()
        {
            var testAssemblyProvider = new TestAssemblyProvider();
            var testAssembly         = Assembly.GetExecutingAssembly();

            testAssemblyProvider.RegisterTestAssembly(testAssembly);

            //ARRANGE
            var runtimePluginLocator = new RuntimePluginLocator(new RuntimePluginLocationMerger(), new SpecFlowPath(), testAssemblyProvider);

            //ACT
            var plugins = runtimePluginLocator.GetAllRuntimePlugins();

            //ASSERT
            plugins.Should().Contain(testAssembly.Location);
        }
Example #5
0
        public void LoadPlugins_Doesnt_load_too_much_assemblies()
        {
            //ARRANGE
            var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();

            var runtimePluginLocator = new RuntimePluginLocator(new RuntimePluginLocationMerger());


            //ACT
            runtimePluginLocator.GetAllRuntimePlugins();


            //ASSERT
            var nowLoadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();

            nowLoadedAssemblies.Should().BeEquivalentTo(loadedAssemblies);
        }
Example #6
0
        public void LoadPlugins_Doesnt_load_too_much_assemblies()
        {
            //ARRANGE
            var loadedAssemblies     = AppDomain.CurrentDomain.GetAssemblies();
            var testAssemblyProvider = new TestAssemblyProvider();

            testAssemblyProvider.RegisterTestAssembly(Assembly.GetExecutingAssembly());
            var runtimePluginLocator = new RuntimePluginLocator(new RuntimePluginLocationMerger(), new SpecFlowPath(), testAssemblyProvider);

            //ACT
            runtimePluginLocator.GetAllRuntimePlugins();


            //ASSERT
            var nowLoadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();

            nowLoadedAssemblies.Should().BeEquivalentTo(loadedAssemblies);
        }