public void CheckCommandCodesWhenResettingToInitialState(Controller controller, SecretPanelSemanticModel semanticModel, HistoryRecordingCommandChannel commandChannel, EventCodeSequences sequences)
        {
            // Arrange
            var expected = new[] { semanticModel.UnlockDoorCmd.Code, semanticModel.LockPanelCmd.Code }.ToList();

            // Act
            controller.HandleEventCode(semanticModel.DoorClosed.Code);
            controller.HandleEventCode(semanticModel.DoorOpened.Code);

            // Assert
            commandChannel.EventCodeHistory.Should().Equal(expected);
        }
Ejemplo n.º 2
0
		public void CurrentStateShouldBeInitializedToStateMachinesStartingState([Frozen] IStateMachine stateMachine, Controller sut)
		{
			// Arrange
			var expected = stateMachine.StartingState;

			// Act
			var result = sut.CurrentState;

			// Assert
			result.Should().BeSameAs(expected);
		}
Ejemplo n.º 3
0
			public void ItShouldNotExecuteTheCommandsOnTheCurrentState(string eventCode, Controller sut)
			{
				// Arrange
				var currentState = sut.CurrentState;

				// Act
				sut.HandleEventCode(eventCode);

				// Assert
				A.CallTo(() => currentState.ExecuteActions(A<ICommandChannel>._)).MustNotHaveHappened();
			}
Ejemplo n.º 4
0
			public void ItShouldNotChangeTheCurrentState(string eventCode, Controller sut)
			{
				// Arrange
				var expected = sut.CurrentState;

				// Act
				sut.HandleEventCode(eventCode);

				// Assert
				sut.CurrentState.Should().BeSameAs(expected);
			}
Ejemplo n.º 5
0
			public void ItShouldExecuteTheCommandsOnTheStartState(IStateMachine stateMachine, [Frozen]ICommandChannel commandChannel, EventCodes eventCodes, Controller sut)
			{
				// Arrange
				var startingState = stateMachine.StartingState;

				sut.HandleEventCode(eventCodes.NewStateEventCode);

				// Act
				sut.HandleEventCode(eventCodes.ResetEventCode);

				// Assert
				A.CallTo(() => startingState.ExecuteActions(commandChannel)).MustHaveHappened(Repeated.Exactly.Once);
			}
Ejemplo n.º 6
0
			public void ItShouldTransitionToTheStartState(IStateMachine stateMachine, EventCodes eventCodes, Controller sut)
			{
				// Arrange
				var startingState = stateMachine.StartingState;

				sut.HandleEventCode(eventCodes.NewStateEventCode);

				// Act
				sut.HandleEventCode(eventCodes.ResetEventCode);

				// Assert
				sut.CurrentState.Should().BeSameAs(startingState);
			}
Ejemplo n.º 7
0
			public void ItShouldExecuteTheCommandsOnTheNewState(IState newState, [Frozen]ICommandChannel commandChannel, EventCodes eventCodes, Controller sut)
			{
				// Arrange

				// Act
				sut.HandleEventCode(eventCodes.NewStateEventCode);

				// Assert
				A.CallTo(() => newState.ExecuteActions(commandChannel)).MustHaveHappened(Repeated.Exactly.Once);
			}
Ejemplo n.º 8
0
			public void ItShouldTransitionToTheNewState(IStateMachine stateMachine, IState newState, EventCodes eventCodes, Controller sut)
			{
				// Arrange

				// Act
				sut.HandleEventCode(eventCodes.NewStateEventCode);

				// Assert
				sut.CurrentState.Should().BeSameAs(newState);
			}
        public void CheckCommandCodesWhenUnlockingPanelViaRouteA(Controller controller, SecretPanelSemanticModel semanticModel, HistoryRecordingCommandChannel commandChannel, EventCodeSequences sequences)
        {
            // Arrange
            var codes = sequences.EventSequenceToUnlockPanelViaRouteA.ToList();

            var expected = new[] { semanticModel.UnlockPanelCmd.Code, semanticModel.LockDoorCmd.Code }.ToList();

            // Act
            codes.ForEach(x => controller.HandleEventCode(x.Code));

            // Assert
            commandChannel.EventCodeHistory.Should().Equal(expected);
        }
        public void UnlockPanelViaRouteB(Controller controller, SecretPanelSemanticModel semanticModel, EventCodeSequences sequences)
        {
            // Arrange
            var codes = sequences.EventSequenceToUnlockPanelViaRouteB.ToList();

            // Act
            codes.ForEach(x => controller.HandleEventCode(x.Code));

            // Assert
            controller.CurrentState.Should().Be(semanticModel.UnlockedPanelState);
        }
        public void SendResetEventAfterMovingToANewState(Controller controller, SecretPanelSemanticModel semanticModel, EventCodeSequences sequences)
        {
            // Arrange
            var codes = sequences.EventSequenceWithReset.ToList();

            // Act
            codes.ForEach(x => controller.HandleEventCode(x.Code));

            // Assert
            controller.CurrentState.Should().Be(semanticModel.IdleState);
        }