public void AddAssembly_SadPath() { var builder = new GraphBuilder(new Registry[0]); builder.AddAssembly("something"); builder.PluginGraph.Log.AssertHasError(101); }
public void Configure_a_family_that_does_not_exist_and_log_an_error_with_PluginGraph() { var builder = new GraphBuilder(new PluginGraph()); builder.ConfigureFamily(new TypePath("a,a"), delegate { }); builder.PluginGraph.Log.AssertHasError(103); }
public void Do_not_try_to_execute_the_action_when_requested_system_object_if_it_cannot_be_created() { var memento = new MemoryInstanceMemento(); var builder = new GraphBuilder(new Registry[0]); builder.WithSystemObject<MementoSource>(memento, "I am going to break here", delegate { Assert.Fail("Wasn't supposed to be called"); }); }
public void graphbuilder_can_add_a_registry_directly() { var graph = new PluginGraph(); var builder = new GraphBuilder(new Registry[0], graph); builder.AddRegistry(typeof (XmlFileRegistry).AssemblyQualifiedName); var container = new Container(graph); TheXmlFileRegistryWasLoadedInto(container); }
public void SetUp() { var doc = new XmlDocument(); doc.LoadXml(xml); var parser = new ConfigurationParser(doc.DocumentElement); var builder = new GraphBuilder(new Registry[0]); parser.ParseProfilesAndMachines(builder); }
public void handles_failures_gracefully_if_the_registry_cannot_be_loaded() { //290 var graph = new PluginGraph(); var builder = new GraphBuilder(graph); builder.AddRegistry("an invalid type name"); graph.Log.ErrorCount.ShouldEqual(1); graph.Log.AssertHasError(290); }
public void SetUp() { var doc = new XmlDocument(); doc.LoadXml(xml); var parser = new ConfigurationParser(doc.DocumentElement); var builder = new GraphBuilder(new PluginGraph()); parser.ParseProfiles(builder); }
public void Call_the_action_on_configure_family_if_the_pluginType_is_found() { var typePath = new TypePath(typeof (IGateway)); bool iWasCalled = false; var builder = new GraphBuilder(new PluginGraph()); builder.ConfigureFamily(typePath, f => { Assert.AreEqual(typeof (IGateway), f.PluginType); iWasCalled = true; }); Assert.IsTrue(iWasCalled); }
public void CanBuildTheInstance() { var builder = new GraphBuilder(new Registry[0]); Type thePluginType = typeof (IGateway); PluginFamily family = builder.PluginGraph.FindFamily(thePluginType); family.DefaultInstanceKey = _memento.InstanceKey; family.AddInstance(_memento); PluginGraph graph = builder.PluginGraph; var manager = new Container(graph); var gateway = (StubbedGateway) manager.GetInstance(typeof (IGateway), _memento.InstanceKey); Assert.IsNotNull(gateway); }
/// <summary> /// Reads the configuration information and returns the PluginGraph definition of /// plugin families and plugin's /// </summary> /// <returns></returns> public PluginGraph Build() { var graphBuilder = new GraphBuilder(_registries, _graph); forAllParsers(p => { _graph.Log.StartSource(p.Description); p.ParseAssemblies(graphBuilder); p.ParseRegistries(graphBuilder); }); forAllParsers(p => p.Parse(graphBuilder)); _graph.Seal(); return _graph; }
public void Create_system_object_successfully_and_call_the_requested_action() { var memento = new MemoryInstanceMemento("XmlFile", "anything"); memento.SetProperty("FilePath", "something"); memento.SetProperty("XPath", "nodeName"); memento.SetProperty("NodeName", "something"); bool iWasCalled = false; var builder = new GraphBuilder(new Registry[0]); builder.WithSystemObject<MementoSource>(memento, "some xml", policy => { Assert.IsInstanceOfType(typeof (XmlFileMementoSource), policy); iWasCalled = true; }); Assert.IsTrue(iWasCalled); }
public void Do_not_call_the_action_on_ConfigureFamily_if_the_type_path_blows_up() { var builder = new GraphBuilder(new PluginGraph()); builder.ConfigureFamily(new TypePath("a,a"), obj => Assert.Fail("Should not be called")); }
public void Log_an_error_for_a_requested_system_object_if_it_cannot_be_created() { var memento = new MemoryInstanceMemento(); var builder = new GraphBuilder(new Registry[0]); builder.WithSystemObject<MementoSource>(memento, "I am going to break here", delegate { }); builder.PluginGraph.Log.AssertHasError(130); }
public void WithType_fails_and_logs_error_with_the_context() { var builder = new GraphBuilder(new Registry[0]); builder.WithType(new TypePath("a,a"), "creating a Plugin", obj => Assert.Fail("Should not be called")); builder.PluginGraph.Log.AssertHasError(131); }
public void WithType_calls_through_to_the_Action_if_the_type_can_be_found() { var builder = new GraphBuilder(new Registry[0]); bool iWasCalled = true; builder.WithType(new TypePath(GetType()), "creating a Plugin", t => { iWasCalled = true; Assert.AreEqual(GetType(), t); }); Assert.IsTrue(iWasCalled); }
void IPluginGraphConfiguration.Configure(PluginGraph graph) { var builder = new GraphBuilder(graph); ParseRegistries(builder); Parse(builder); }