public void is_newStateFireSameAsCurrentState_ReturnTrue(string oldState, string currentState, string newState) { // Arrange BuildingController bc = new BuildingController(ID); // Act bool oState = bc.SetCurrentState(oldState); bool cState = bc.SetCurrentState(currentState); bool nState = bc.SetCurrentState(newState); // Assert Assert.IsTrue(nState); }
public void is_stateChangeFireSequenceInvalid_ReturnFalse(string oldState, string currentState, string newState) { // Arrange BuildingController bc = new BuildingController(ID); // Act bool oState = bc.SetCurrentState(oldState); bool cState = bc.SetCurrentState(currentState); bool nState = bc.SetCurrentState(newState); // Assert Assert.IsFalse(nState); }
public void is_stateChangeSequencialValid_ReturnTrue(string state, string newState) { // Arrange BuildingController bc = new BuildingController(ID); // Act bool result = bc.SetCurrentState(state); bool fResult = bc.SetCurrentState(newState); // Assert Assert.IsTrue(fResult); }
public void is_StateValid_ReturTrue(string state) { // Arrange // Act BuildingController bc = new BuildingController(ID); bool result = bc.SetCurrentState(state); // Assert Assert.IsTrue(result); }
public void is_StateInvalid_ReturnFalse(string state) { // Arrange string id = "newId"; BuildingController bc = new BuildingController(id); // Act bool result = bc.SetCurrentState(state); // Assert Assert.IsFalse(result); }
public void is_stateChangesToOpenFromFireStatesFailsToUnlocksAllDoors_ReturnFalse(string Oldstate, string currentState, string newState) { // Arrange var stubDoorManager = Substitute.For <IDoorManager>(); var stubFireAlarmManager = Substitute.For <IFireAlarmManager>(); var stubLightManager = Substitute.For <ILightManager>(); var stubWebService = Substitute.For <IWebService>(); var stubEmailService = Substitute.For <IEmailService>(); stubDoorManager.OpenAllDoors().Returns(true, false); // Act BuildingController bc = new BuildingController(ID, stubLightManager, stubFireAlarmManager, stubDoorManager, stubWebService, stubEmailService); bool stateFirst = bc.SetCurrentState(Oldstate); bool stateSecond = bc.SetCurrentState(currentState); bool result = bc.SetCurrentState(newState); bool expected = false; // Assert Assert.AreEqual(expected, result); }
public void is_stateChangesToOpenFailToUnlocksAllDoors_ReturnFalse() { // Arrange var stubDoorManager = Substitute.For <IDoorManager>(); stubDoorManager.OpenAllDoors().Returns(false); // Act BuildingController bc = new BuildingController(ID, GetMockLightManager(), GetMockFireAlarmManager(), stubDoorManager, GetMockIWebService(), GetMockEmailService()); bool result = bc.SetCurrentState(STATE_OPEN); // Assert Assert.AreEqual(stubDoorManager.OpenAllDoors(), result); }
public void is_StateChangesToClosedLockAllDoorsAndTurnOffLights_ReturnTrue() { // Arrange var stubDoorManager = Substitute.For <IDoorManager>(); var stubLightManager = Substitute.For <ILightManager>(); stubDoorManager.LockAllDoors().Returns(true); /// stubLightManager.SetAllLights(false); // Act BuildingController bc = new BuildingController(ID, stubLightManager, GetMockFireAlarmManager(), stubDoorManager, GetMockIWebService(), GetMockEmailService()); bool result = bc.SetCurrentState(STATE_CLOSED); bool expected = true; // Assert Assert.AreEqual(expected, result); }
public void is_state_FireAlarm_EnableAlarmUnlockAllDoorsTurnOnLights_ReturnTrue() { // Arrange var stubFireAlarmManager = Substitute.For <IFireAlarmManager>(); var stubDoorManager = Substitute.For <IDoorManager>(); var stubLightManager = Substitute.For <ILightManager>(); var stubWebService = Substitute.For <IWebService>(); var stubIEmailService = Substitute.For <IEmailService>(); // Act BuildingController bc = new BuildingController(ID, stubLightManager, stubFireAlarmManager, stubDoorManager, stubWebService, stubIEmailService); bool result = bc.SetCurrentState(STATE_FIRE_ALARM); // Assert stubWebService.Received().LogFireAlarm("fire alarm"); stubFireAlarmManager.Received().SetAlarm(true); stubLightManager.Received().SetAllLights(true); stubDoorManager.Received().OpenAllDoors(); }
public void if_LogFireAlarmThrowsException_SendEmail() { // Arrange var stubFireAlarmManager = Substitute.For <IFireAlarmManager>(); var stubDoorManager = Substitute.For <IDoorManager>(); var stubLightManager = Substitute.For <ILightManager>(); var mockWebService = Substitute.For <IWebService>(); var stubEmailService = Substitute.For <IEmailService>(); mockWebService.When( service => service.LogFireAlarm(Arg.Any <string>())). Do(info => { throw new Exception(); }); // Act BuildingController bc = new BuildingController(ID, stubLightManager, stubFireAlarmManager, stubDoorManager, mockWebService, stubEmailService); bc.SetCurrentState(STATE_FIRE_ALARM); // Assert stubEmailService.Received().SendEmail(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()); }