Exemplo n.º 1
0
        public void CanInjectInstanceThroughFluentConfiguration()
        {
            var instance = new ClassWithNoDependencies();
            store.Register(p => p.Service<IService>("test")
                                    .Instance(instance));

            //TODO: Maybe clean this up. Too much implementation detail
            var execute = store.GetRegistrationsForService(typeof(IService)).First().Lifestyle.Execute(null);
            Assert.Same(instance, execute);
        }
        public void CanInsertInstanceWithoutName()
        {
            var store = new ComponentStore();
            var instance = new ClassWithNoDependencies();
            store.AddInstance<IService>(instance);
            var container = new PandoraContainer(store);

            var service = container.Resolve<IService>();

            Assert.Same(instance, service);
        }
Exemplo n.º 3
0
        public void CanInsertInstanceWithoutName()
        {
            var store    = new ComponentStore();
            var instance = new ClassWithNoDependencies();

            store.AddInstance <IService>(instance);
            var container = new PandoraContainer(store);

            var service = container.Resolve <IService>();

            Assert.Same(instance, service);
        }
Exemplo n.º 4
0
        public void CanInjectInstanceThroughFluentConfiguration()
        {
            var instance = new ClassWithNoDependencies();

            store.Register(p => p.Service <IService>("test")
                           .Instance(instance));

            //TODO: Maybe clean this up. Too much implementation detail
            var execute = store.GetRegistrationsForService(typeof(IService)).First().Lifestyle.Execute(null);

            Assert.Same(instance, execute);
        }
Exemplo n.º 5
0
 public ClassWithDependencies(ClassWithNoDependencies dependency)
 {
     Dependency = dependency;
 }
Exemplo n.º 6
0
 public ClassWithDependencies(ClassWithNoDependencies dependency)
 {
     Dependency = dependency ?? throw new ArgumentNullException(nameof(dependency));
 }