Пример #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");
        }
Пример #2
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);
        }
Пример #3
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);
        }