public void SetUp()
        {
            Context = new UriGeneratorTestContext();

            var internalDependencyResolver             = new InternalDependencyResolver();
            ICommunicationContext communicationContext = MockRepository.GenerateStub <ICommunicationContext>();

            Context.BaseUri = new Uri("http://localhost/");
            communicationContext.Stub(x => x.ApplicationBaseUri).Return(Context.BaseUri);
            internalDependencyResolver.AddDependencyInstance <ICommunicationContext>(communicationContext);
            Context.UriResolver = MockRepository.GenerateStub <IUriResolver>();
            internalDependencyResolver.AddDependencyInstance <IUriResolver>(Context.UriResolver);
            Context.Target = new UriGenerator(Context.UriResolver);
            DependencyManager.SetResolver(internalDependencyResolver);
        }
        protected static IPipelineAsync CreatePipeline(
            Type callGraphGeneratorType,
            Type[] contributorTypes,
            Action <StartupProperties> options = null)
        {
            var resolver = new InternalDependencyResolver();

            resolver.AddDependencyInstance <IDependencyResolver>(resolver);
            resolver.AddDependency <IPipelineInitializer, ThreePhasePipelineInitializer>();
            resolver.AddDependency(typeof(IGenerateCallGraphs), callGraphGeneratorType, DependencyLifetime.Transient);

            if (callGraphGeneratorType != null)
            {
                resolver.AddDependency(typeof(IGenerateCallGraphs), callGraphGeneratorType,
                                       DependencyLifetime.Singleton);
            }

            foreach (var type in contributorTypes)
            {
                resolver.AddDependency(typeof(IPipelineContributor), type, DependencyLifetime.Singleton);
            }

            var runner = resolver.Resolve <IPipelineInitializer>();


            var opt = new StartupProperties {
                OpenRasta = { Pipeline = { Validate = true } }
            };

            options?.Invoke(opt);
            return(runner.Initialize(opt));
        }
Example #3
0
        protected IPipeline CreatePipeline(Type callGraphGeneratorType, Type[] contributorTypes)
        {
            var resolver = new InternalDependencyResolver();

            resolver.AddDependencyInstance <IDependencyResolver>(resolver);
            resolver.AddDependency <IPipelineContributor, BootstrapperContributor>();
            resolver.AddDependency <T>();
            //resolver.AddDependency<IPipeline, T>(DependencyLifetime.Singleton);


            if (callGraphGeneratorType != null)
            {
                resolver.AddDependency(typeof(IGenerateCallGraphs), callGraphGeneratorType, DependencyLifetime.Singleton);
            }

            foreach (var type in contributorTypes)
            {
                resolver.AddDependency(typeof(IPipelineContributor), type, DependencyLifetime.Singleton);
            }

            var runner = resolver.Resolve <T>();

            runner.Initialize();
            return(runner);
        }
Example #4
0
        private void OpenRastaRegistrar(CommandProcessor commandProcessor)
        {
            _internalDependencyResolver = new InternalDependencyResolver();

            _internalDependencyResolver.AddDependencyInstance <IAmACommandProcessor>(commandProcessor, DependencyLifetime.Singleton);
            _internalDependencyResolver.AddDependency <ITaskRetriever, TaskRetriever>(DependencyLifetime.Singleton);
            _internalDependencyResolver.AddDependency <ITaskListRetriever, TaskListRetriever>(DependencyLifetime.Singleton);
            _internalDependencyResolver.AddDependency <ITasksDAO, TasksDAO>(DependencyLifetime.Singleton);
        }
Example #5
0
        protected override void SetUp()
        {
            base.SetUp();
            var resolver = new InternalDependencyResolver();

            DependencyManager.SetResolver(resolver);
            resolver.AddDependency <IUriResolver, TemplatedUriResolver>();
            resolver.AddDependencyInstance <IDependencyResolver>(resolver);
            UriResolver = DependencyManager.GetService <IUriResolver>();
        }
        public void the_hydrator_is_executed()
        {
            var processor = new Mock<IOperationHydrator>(MockBehavior.Strict);
            var operations = new[] { new Mock<IOperation>().Object };
            var resolver = new InternalDependencyResolver();
            processor.Expect(x => x.Process(It.IsAny<IEnumerable<IOperation>>())).Returns((IEnumerable<IOperation> op) => op);

            resolver.AddDependencyInstance<IOperationHydrator>(processor.Object);
            var contrib = new OperationHydratorContributor(resolver);
            contrib.ProcessOperations(operations);

            processor.VerifyAll();
        }
        public void the_hydrator_is_executed()
        {
            var processor  = new Mock <IOperationHydrator>(MockBehavior.Strict);
            var operations = new[] { new Mock <IOperation>().Object };
            var resolver   = new InternalDependencyResolver();

            processor.Setup(x => x.Process(It.IsAny <IEnumerable <IOperation> >())).Returns((IEnumerable <IOperation> op) => op);

            resolver.AddDependencyInstance <IOperationHydrator>(processor.Object);
            var contrib = new OperationHydratorContributor(resolver);

            contrib.ProcessOperations(operations);

            processor.VerifyAll();
        }
        public void resolve_succeeds()
        {
            var resolver = new InternalDependencyResolver();

            resolver.AddDependency <IContextStore, AmbientContextStore>();

            resolver.AddDependency <Contributor>(DependencyLifetime.Singleton);
            resolver.AddDependency <ErrorCollector>(DependencyLifetime.Transient);

            var contributor = resolver.Resolve <Contributor>();

            using (new ContextScope(new AmbientContext()))
                using (resolver.CreateRequestScope())
                {
                    resolver.AddDependencyInstance(new Request(), DependencyLifetime.PerRequest);
                    var result = contributor.Factory();
                    result.ShouldHaveSingleItem();
                }
        }
Example #9
0
        private void OpenRastaRegistrar(CommandProcessor commandProcessor)
        {
            _internalDependencyResolver = new InternalDependencyResolver();

            _internalDependencyResolver.AddDependencyInstance<IAmACommandProcessor>(commandProcessor, DependencyLifetime.Singleton);
            _internalDependencyResolver.AddDependency<ITaskRetriever, TaskRetriever>(DependencyLifetime.Singleton);
            _internalDependencyResolver.AddDependency<ITaskListRetriever, TaskListRetriever>(DependencyLifetime.Singleton);
            _internalDependencyResolver.AddDependency<ITasksDAO, TasksDAO>(DependencyLifetime.Singleton);
        }
        public void CanUseConstructedObject()
        {
            IDependencyResolver container = new InternalDependencyResolver();
            container.AddDependency<SweetShop>(DependencyLifetime.Transient);
            container.AddDependency<SweetVendingMachine>(DependencyLifetime.Transient);
            container.AddDependencyInstance<IJellybeanDispenser>(new AnyJellybeanDispenser(Jellybean.Cocoa));

            SweetShop sweetShop = container.Resolve<SweetShop>();

            Assert.AreEqual(Jellybean.Cocoa, sweetShop.DispenseJellyBean());
        }