public void when_retrieving_by_try_get_named_instance_that_does_exist()
        {
            var red   = new ColorService("red");
            var green = new ColorService("green");

            var          graph  = new PluginGraph();
            PluginFamily family = graph.FindFamily(typeof(IService));

            family.AddInstance(new ObjectInstance(red).WithName("red"));
            family.AddInstance(new ObjectInstance(green).WithName("green"));

            var session = new BuildSession(graph);

            session.TryGetInstance <IService>("red").ShouldBeTheSameAs(red);
            session.TryGetInstance <IService>("green").ShouldBeTheSameAs(green);
        }
        public void when_retrieving_by_try_get_instance_for_instance_that_does_exist()
        {
            var session    = new BuildSession();
            var theService = new ColorService("red");

            session.RegisterDefault(typeof(IService), theService);

            session.TryGetInstance <IService>().ShouldBeTheSameAs(theService);
        }
Example #3
0
        public void when_retrieving_with_try_get_instance_with_nongeneric_type_that_does_exist()
        {
            var theService = new ColorService("red");
            var registry   = new Registry();

            registry.For <IService>().Use(theService);
            var session = new BuildSession(registry.Build());

            session.TryGetInstance(typeof(IService)).ShouldBeTheSameAs(theService);
        }
Example #4
0
        public void when_retrieving_by_try_get_named_instance_with_nongeneric_type_that_does_exist()
        {
            var red   = new ColorService("red");
            var green = new ColorService("green");

            var registry = new Registry();

            registry.For <IService>().Add(red).Named("red");
            registry.For <IService>().Add(green).Named("green");
            var graph = registry.Build();

            var session = new BuildSession(graph);

            session.TryGetInstance(typeof(IService), "red").ShouldBeTheSameAs(red);
        }
        public void when_retrieving_with_try_get_instance_for_instance_that_does_not_exists()
        {
            var session = new BuildSession(new PluginGraph());

            session.TryGetInstance <IService>().ShouldBeNull();
        }
        public void when_retrieving_by_try_get_named_instance_that_does_not_exist()
        {
            var session = new BuildSession();

            session.TryGetInstance <IService>("red").ShouldBeNull();
        }
 public void when_retrieving_with_try_get_instance_with_nongeneric_type_that_does_not_exist()
 {
     var session = new BuildSession(new PluginGraph());
     session.TryGetInstance(typeof(IService)).ShouldBeNull();
 }
        public void when_retrieving_with_try_get_instance_with_nongeneric_type_that_does_exist()
        {
            var theService = new ColorService("red");
            var registry = new Registry();
            registry.For<IService>().Use(theService);
            var session = new BuildSession(registry.Build());

            session.TryGetInstance(typeof(IService)).ShouldBeTheSameAs(theService);
        }
 public void when_retrieving_with_try_get_instance_for_instance_that_does_not_exists()
 {
     var session = new BuildSession(new PluginGraph());
     session.TryGetInstance<IService>().ShouldBeNull();
 }
        public void when_retrieving_by_try_get_named_instance_with_nongeneric_type_that_does_exist()
        {
            var red = new ColorService("red");
            var green = new ColorService("green");

            var registry = new Registry();
            registry.For<IService>().Add(red).Named("red");
            registry.For<IService>().Add(green).Named("green");
            var graph = registry.Build();

            var session = new BuildSession(graph);
            session.TryGetInstance(typeof(IService), "red").ShouldBeTheSameAs(red);
        }
 public void when_retrieving_by_try_get_named_instance_that_does_not_exist()
 {
     var session = new BuildSession();
     session.TryGetInstance<IService>("red").ShouldBeNull();
 }
        public void when_retrieving_by_try_get_named_instance_that_does_exist()
        {
            var red = new ColorService("red");
            var green = new ColorService("green");

            var graph = new PluginGraph();
            PluginFamily family = graph.FindFamily(typeof (IService));
            family.AddInstance(new ObjectInstance(red).WithName("red"));
            family.AddInstance(new ObjectInstance(green).WithName("green"));

            var session = new BuildSession(graph);
            session.TryGetInstance<IService>("red").ShouldBeTheSameAs(red);
            session.TryGetInstance<IService>("green").ShouldBeTheSameAs(green);
        }
        public void when_retrieving_by_try_get_instance_for_instance_that_does_exist()
        {
            var session = new BuildSession();
            var theService = new ColorService("red");
            session.RegisterDefault(typeof (IService), theService);

            session.TryGetInstance<IService>().ShouldBeTheSameAs(theService);
        }
Example #14
0
        public void when_retrieving_by_try_get_named_instance_with_type_that_does_not_exist()
        {
            var session = new BuildSession(new PluginGraph());

            session.TryGetInstance(typeof(IService), "yo").ShouldBeNull();
        }