public void TestDetach_WithNoSelectedCore_ShouldReturnFailureMessage() { ICommand testCommand = new DetachFragmentCommand(this.testNuclearPowerPlant); String actualMessage = testCommand.Execute(); String expectedMessage = "Failed to detach Fragment!"; Assert.AreEqual(expectedMessage, actualMessage, "DetachFragment command does not work correctly!"); }
public void TestDetach_WithSelectedCore_WithNoFragments_ShouldReturnFailureMessage() { ICore dummyCore = new SystemCore("A", 100); this.testNuclearPowerPlant.AttachCore(dummyCore); this.testNuclearPowerPlant.SelectCore("A"); ICommand testCommand = new DetachFragmentCommand(this.testNuclearPowerPlant); String actualMessage = testCommand.Execute(); String expectedMessage = "Failed to detach Fragment!"; Assert.AreEqual(expectedMessage, actualMessage, "DetachFragment command does not work correctly!"); }
public void TestDetach_WithSelectedCore_WithOneFragment_ShouldReturnSuccessMessage() { ICore dummyCore = new SystemCore("A", 100); IFragment dummyFragment = new NuclearFragment("Test", 1); dummyCore.AttachFragment(dummyFragment); this.testNuclearPowerPlant.AttachCore(dummyCore); this.testNuclearPowerPlant.SelectCore("A"); ICommand testCommand = new DetachFragmentCommand(this.testNuclearPowerPlant); String actualMessage = testCommand.Execute(); String expectedMessage = "Successfully detached Fragment Test from Core A!"; Assert.AreEqual(expectedMessage, actualMessage, "DetachFragment command does not work correctly!"); }
public ICommand DispatchCommand(string commandName, string[] arguments) { ICommand command = null; switch (commandName) { case "CreateCore": command = new CreateCoreCommand(this.NuclearPowerPlant, (CoreType)Enum.Parse(typeof(CoreType), arguments[0]), this.NuclearPowerPlant.NextCoreName, int.Parse(arguments[1])); break; case "RemoveCore": command = new RemoveCoreCommand(this.NuclearPowerPlant, arguments[0]); break; case "SelectCore": command = new SelectCommand(this.NuclearPowerPlant, arguments[0]); break; case "AttachFragment": command = new AttachFragmentCommand(this.NuclearPowerPlant, (FragmentType)Enum.Parse(typeof(FragmentType), arguments[0]), arguments[1], int.Parse(arguments[2])); break; case "DetachFragment": command = new DetachFragmentCommand(this.NuclearPowerPlant); break; case "Status": command = new StatusCommand(this.NuclearPowerPlant); break; case "System Shutdown": break; } return(command); }