Exemplo n.º 1
0
        public void ShouldAct()
        {
            // Arrange
            MockCountdownTimerElapsedAction nextAction     = new MockCountdownTimerElapsedAction.Builder().Act().Build();
            MockCountdownTimer          mockCountdownTimer = new MockCountdownTimer.Builder().Build();
            CountdownTimerElapsedAction subject            = new CountdownTimerElapsedAction(nextAction);

            // Act
            subject.Act(mockCountdownTimer);

            // Assert
            nextAction.AssertActInvokedWith(mockCountdownTimer);
        }
Exemplo n.º 2
0
        public void ShouldGuardWhenFinished()
        {
            // Arrange
            MockCountdownTimerElapsedAction nextAction        = new MockCountdownTimerElapsedAction.Builder().Build();
            MockCountdownState mockCountdownState             = new MockCountdownState.Builder().Finished(Bool.True).Build();
            MockCountdownTimer mockCountdownTimer             = new MockCountdownTimer.Builder().CountdownState(mockCountdownState).Close().Build();
            CountdownTimerElapsedAction_FinishedGuard subject = new CountdownTimerElapsedAction_FinishedGuard(nextAction);

            // Act
            subject.Act(mockCountdownTimer);

            // Assert
            mockCountdownTimer.AssertCloseInvoked();
        }
Exemplo n.º 3
0
        public void ShouldNextActWhenNotFinished()
        {
            // Arrange
            MockCountdownTimerElapsedAction nextAction        = new MockCountdownTimerElapsedAction.Builder().Act().Build();
            MockCountdownState mockCountdownState             = new MockCountdownState.Builder().Finished(Bool.False).Build();
            MockCountdownTimer mockCountdownTimer             = new MockCountdownTimer.Builder().CountdownState(mockCountdownState).Build();
            CountdownTimerElapsedAction_FinishedGuard subject = new CountdownTimerElapsedAction_FinishedGuard(nextAction);

            // Act
            subject.Act(mockCountdownTimer);

            // Assert
            nextAction.AssertActInvokedWith(mockCountdownTimer);
        }
        public void ShouldAct()
        {
            //Arrange
            MockMainForm                  mockMainForm       = new MockMainForm.Builder().Build();
            MockCountdownTimer            mockCountdownTimer = new MockCountdownTimer.Builder().Build();
            MockCountdownTimerStartAction nextAction         = new MockCountdownTimerStartAction.Builder().Act().Build();
            ShortBreakTimerStartAction    subject            = new PrivateCtor <ShortBreakTimerStartAction>(nextAction);

            //Act
            subject.Act(mockMainForm, mockCountdownTimer);

            //Assert
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTimer);
        }
        public void ShouldNextActAndInvoke()
        {
            // Arrange
            MockCountdownTimerElapsedAction nextAction = new MockCountdownTimerElapsedAction.Builder().Act().Build();
            MockCountdownTimer mockCountdownTimer      = new MockCountdownTimer.Builder().Invoke().Build();
            CountdownTimerElapsedAction_Update subject = new CountdownTimerElapsedAction_Update(nextAction);

            // Act
            subject.Act(mockCountdownTimer);

            // Assert
            nextAction.AssertActInvokedWith(mockCountdownTimer);
            mockCountdownTimer.AssertInvokeInvokedWith(TimerProgress.More);
        }
        public void ShouldGuardWhenLast()
        {
            // Arrange
            MockCountdownTimerElapsedAction nextAction    = new MockCountdownTimerElapsedAction.Builder().Build();
            MockCountdownState mockCountdownState         = new MockCountdownState.Builder().Last(Bool.True).Build();
            MockCountdownTimer mockCountdownTimer         = new MockCountdownTimer.Builder().CountdownState(mockCountdownState).Invoke().Build();
            CountdownTimerElapsedAction_LastGuard subject = new CountdownTimerElapsedAction_LastGuard(nextAction);

            // Act
            subject.Act(mockCountdownTimer);

            // Assert
            mockCountdownTimer.AssertInvokeInvokedWith(TimerProgress.Last);
        }
        public void ShouldStartTimer()
        {
            //Arrange
            MockMainForm                         mockMainForm       = new MockMainForm.Builder().Build();
            MockCountdownTimer                   mockCountdownTimer = new MockCountdownTimer.Builder().Start().Build();
            MockCountdownTimerStartAction        nextAction         = new MockCountdownTimerStartAction.Builder().Act().Build();
            CountdownTimerStartAction_StartTimer subject            = new CountdownTimerStartAction_StartTimer(nextAction);


            //Act
            subject.Act(mockMainForm, mockCountdownTimer);

            //Assert
            mockCountdownTimer.AssertStartInvoked();
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTimer);
        }
Exemplo n.º 8
0
        public void ShouldInvokeActionGivenStart()
        {
            //Arrange
            MockMainForm                   mockMainForm       = new MockMainForm.Builder().Build();
            MockCountdownTimer             mockCountdownTimer = new MockCountdownTimer.Builder().Build();
            MockCountdownTimerStartAction  startAction        = new MockCountdownTimerStartAction.Builder().Act().Build();
            MockCountdownTimerUpdateAction updateAction       = new MockCountdownTimerUpdateAction.Builder().Build();

            PomodoroPeriod subject = new TestPomodoroPeriod(mockCountdownTimer, startAction, updateAction);

            //Act
            subject.SetMainForm(mockMainForm);
            subject.Start();

            //Assert
            startAction.AssertActInvokedWith(mockMainForm, mockCountdownTimer);
        }
Exemplo n.º 9
0
        public void ShouldInvokeUpdateOnTrigger()
        {
            //Arrange
            MockCountdownTime              mockCountdownTime  = new MockCountdownTime.Builder().Build();
            MockMainForm                   mockMainForm       = new MockMainForm.Builder().Build();
            MockCountdownTimer             mockCountdownTimer = new MockCountdownTimer.Builder().Build();
            MockCountdownTimerStartAction  startAction        = new MockCountdownTimerStartAction.Builder().Build();
            MockCountdownTimerUpdateAction updateAction       = new MockCountdownTimerUpdateAction.Builder().Act().Build();
            PomodoroPeriod                 subject            = new TestPomodoroPeriod(mockCountdownTimer, startAction, updateAction);

            subject.SetMainForm(mockMainForm);

            //Act
            mockCountdownTimer.TriggerElapsed(mockCountdownTime, TimerProgress.Last);

            //Assert
            updateAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, TimerProgress.Last);
        }
        public void ShouldDisableLongBreak()
        {
            //Arrange
            MockEnabled                   mockEnabled               = new MockEnabled.Builder().Disable().Build();
            MockMainForm                  mockMainForm              = new MockMainForm.Builder().LongBreakStartEnabled(mockEnabled).Build();
            MockCountdownTimer            mockCountdownTimer        = new MockCountdownTimer.Builder().Build();
            MockCountdownTimerStartAction nextAction                = new MockCountdownTimerStartAction.Builder().Act().Build();
            CountdownTimerStartAction_DisableLongBreakStart subject = new CountdownTimerStartAction_DisableLongBreakStart(nextAction);


            //Act
            subject.Act(mockMainForm, mockCountdownTimer);

            //Assert
            mockEnabled.Disable();
            mockMainForm.AssertLongBreakStartEnabledInvoked();
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTimer);
        }