Exemple #1
0
        public void returns_missing_instance_if_it_exists_and_the_requested_instance_is_not_found()
        {
            var graph   = new PluginGraph();
            var family  = graph.Families[typeof(IWidget)];
            var missing = new ObjectInstance(new AWidget());

            family.MissingInstance = missing;

            graph.FindInstance(typeof(IWidget), "anything").ShouldBeTheSameAs(missing);
            graph.FindInstance(typeof(IWidget), Guid.NewGuid().ToString()).ShouldBeTheSameAs(missing);
        }
        public void find_instance_negative_when_family_does_not_exist_does_not_create_family()
        {
            var graph = new PluginGraph();

            graph.FindInstance(typeof(BigThingy), "blue").ShouldBeNull();
            graph.Families.Has(typeof(BigThingy)).ShouldBeFalse();
        }
        public void find_instance_negative_when_family_does_exist_but_instance_does_not()
        {
            var graph = new PluginGraph();

            graph.Families[typeof(BigThingy)].AddInstance(new SmartInstance <BigThingy>().Named("red"));

            graph.FindInstance(typeof(BigThingy), "blue").ShouldBeNull();
        }
        public void find_instance_positive()
        {
            var graph    = new PluginGraph();
            var instance = new SmartInstance <BigThingy>().Named("red");

            graph.Families[typeof(BigThingy)].AddInstance(instance);

            graph.FindInstance(typeof(BigThingy), "red").ShouldBeTheSameAs(instance);
        }
        public void find_instance_can_use_missing_instance()
        {
            var graph    = new PluginGraph();
            var instance = new SmartInstance <BigThingy>().Named("red");

            graph.Families[typeof(BigThingy)].MissingInstance = instance;

            graph.FindInstance(typeof(BigThingy), "green")
            .ShouldBeTheSameAs(instance);
        }
Exemple #6
0
 public Instance FindInstance(Type pluginType, string name)
 {
     return(_pluginGraph.FindInstance(pluginType, name) ?? _parent.Instances.FindInstance(pluginType, name));
 }
Exemple #7
0
 public Instance FindInstance(Type pluginType, string name)
 {
     return(_outer.FindInstance(pluginType, name) ?? _parent.FindInstance(pluginType, name));
 }