public void TestAttach_WithUnselectedCore_ShouldReturnFailureMessage() { ICommand testCommand = new AttachFragmentCommand( this.testNuclearPowerPlant, FragmentType.Nuclear, "Test", 1); String actualMessage = testCommand.Execute(); String expectedMessage = "Failed to attach Fragment Test!"; Assert.AreEqual(expectedMessage, actualMessage, "AttachFragment command does not work correctly!"); }
public void TestAttach_WithSelectedCore_ShouldReturnSuccessMessage() { ICore dummyCore = new SystemCore("A", 100); this.testNuclearPowerPlant.AttachCore(dummyCore); this.testNuclearPowerPlant.SelectCore("A"); ICommand testCommand = new AttachFragmentCommand( this.testNuclearPowerPlant, FragmentType.Nuclear, "Test", 1); String actualMessage = testCommand.Execute(); String expectedMessage = "Successfully attached Fragment Test to Core A!"; Assert.AreEqual(expectedMessage, actualMessage, "AttachFragment command does not work correctly!"); }
public void TestAttach_WithInvalidPressureAffection_ShouldReturnFailureMessage() { ICore dummyCore = new SystemCore("A", 100); this.testNuclearPowerPlant.AttachCore(dummyCore); this.testNuclearPowerPlant.SelectCore("A"); ICommand testCommand = new AttachFragmentCommand( this.testNuclearPowerPlant, FragmentType.Nuclear, "Test", -1); String actualMessage = testCommand.Execute(); String expectedMessage = "Failed to attach Fragment Test!"; Assert.AreEqual(expectedMessage, actualMessage, "AttachFragment 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); }