private IRotorContext CreateRotorContextWithThisServiceLocator(
            DependencyResolverMockServiceLocator serviceLocator)
        {
            var fakeRotorContext = new Mock <IRotorContext>();

            fakeRotorContext.Setup(x => x.ServiceLocator)
            .Returns(serviceLocator);
            return(fakeRotorContext.Object);
        }
        public void Passes_the_service_locator_from_rotorcontext_to_the_TurbineDependencyResolver()
        {
            var expected = new DependencyResolverMockServiceLocator();

            expected.ReturnAResolutionErrorWhenResolving();

            var blade = new DependencyResolverBlade();

            var fakeRotorContext = CreateRotorContextWithThisServiceLocator(expected);

            blade.Spin(fakeRotorContext);

            Assert.AreSame(expected, ((TurbineDependencyResolver)DependencyResolver.Current).ServiceLocator);
        }
        Sets_the_dependency_resolver_to_an_instance_of_TurbineDependencyResolver_when_no_IDependencyResolver_is_registered
            ()
        {
            var blade = new DependencyResolverBlade();

            var serviceLocator = new DependencyResolverMockServiceLocator();

            serviceLocator.ReturnAResolutionErrorWhenResolving();

            var fakeRotorContext = CreateRotorContextWithThisServiceLocator(serviceLocator);

            blade.Spin(fakeRotorContext);

            Assert.IsInstanceOfType(typeof(TurbineDependencyResolver), DependencyResolver.Current);
        }
        public void Sets_the_current_IDependencyResolver_to_one_from_the_service_locator()
        {
            var expected = new Mock <IDependencyResolver>().Object;

            var locator = new DependencyResolverMockServiceLocator();

            locator.ReturnThisDependencyResolver(expected);

            var blade = new DependencyResolverBlade();

            var fakeRotorContext = CreateRotorContextWithThisServiceLocator(locator);

            blade.Spin(fakeRotorContext);

            Assert.AreSame(expected, DependencyResolver.Current);
        }