Example #1
0
        public void Should_be_able_to_override_test_runner_registration_from_a_plugin()
        {
            var pluginWithCustomTestThreadDependencies = new PluginWithCustomTestThreadDependencies(oc => oc.RegisterTypeAs <CustomTraceListener, ITraceListener>());
            var runtimePluginEvents = new RuntimePluginEvents();

            pluginWithCustomTestThreadDependencies.Initialize(runtimePluginEvents, new RuntimePluginParameters(), new UnitTestProviderConfiguration());

            var container = new ObjectContainer();

            runtimePluginEvents.RaiseCustomizeTestThreadDependencies(container);
            var traceListener = container.Resolve <ITraceListener>();

            traceListener.Should().BeOfType(typeof(CustomTraceListener));
        }
Example #2
0
        public void Test_runner_dependencies_from_a_plugin_are_not_in_the_global_container()
        {
            StringConfigProvider configurationHolder   = GetConfigWithPlugin();
            var pluginWithCustomTestThreadDependencies = new PluginWithCustomTestThreadDependencies(oc => oc.RegisterTypeAs <CustomDependency, ICustomDependency>());
            var runtimePluginEvents = new RuntimePluginEvents();

            pluginWithCustomTestThreadDependencies.Initialize(runtimePluginEvents, new RuntimePluginParameters(), new UnitTestProviderConfiguration());

            var container = new ObjectContainer();

            runtimePluginEvents.RaiseRegisterGlobalDependencies(container);

            Action resolveAction = () => container.Resolve <ICustomDependency>();

            resolveAction.Should().Throw <ObjectContainerException>();
        }