public void Should_Execute_Plugin() { IBroker broker = new Broker(); IAgentEngine agent = new AgentEngine( ); IAllocationDefinition definition = new AllocationDefinition(2); IExecutionSlot slot = new ExecutionSlot(definition); broker.Add(agent); agent.PluginManager.Install(definition); agent.ExecutionManager.Add( slot ); definition.Add(DTO.NewPluginInfoTestPlugin); IPlugin completedPlugin = null; TestPlugin testPlugin = new TestPlugin(100); broker.ExecuteCompleted += delegate(object sender, ObjectEventArgs<IPlugin> eventArgs) { completedPlugin = eventArgs.EventObject; }; broker.Execute(testPlugin); Assert.AreEqual(slot, agent.ExecutionManager[definition]); Assert.AreEqual(1, agent.ExecutionManager[definition].UsedSlots, "Slots Used"); Timing.WaitWhile(() => completedPlugin == null, 1000); Assert.AreEqual(testPlugin, completedPlugin); Assert.AreEqual(0, agent.ExecutionManager[definition].UsedSlots); Assert.AreEqual(PluginStatus.Executed, testPlugin.Status); }
public void AddDefinition( IAllocationDefinition definition ) { IExecutionSlot executionSlot = new ExecutionSlot( definition ); PluginManager.Install( definition ); ExecutionManager.Add( executionSlot ); }
public void Should_Throw_Exception_When_Plugin_Isnt_Installed_When_Rollback() { IBroker broker = new Broker(); IAgentEngine agent = new AgentEngine(); IAllocationDefinition definition = new AllocationDefinition(2); IExecutionSlot slot = new ExecutionSlot(definition); broker.Add(agent); agent.PluginManager.Install(definition); agent.ExecutionManager.Add(slot); TestPlugin testPlugin = new TestPlugin(); broker.Rollback(testPlugin); }
public void Should_Throw_Exception_When_No_Slots_Are_Available_For_Rollback() { IBroker broker = new Broker(); IAgentEngine agent = new AgentEngine(); IAllocationDefinition definition = new AllocationDefinition(2); IExecutionSlot slot = new ExecutionSlot(definition); broker.Add(agent); definition.Add(DTO.NewPluginInfoTestPlugin); agent.PluginManager.Install(definition); agent.ExecutionManager.Add(slot); broker.Rollback(new TestPlugin(600)); broker.Rollback(new TestPlugin(600)); broker.Rollback(new TestPlugin(600)); }