コード例 #1
0
        public void Close_ShouldInvokeTimerBookEnd()
        {
            //Arrange
            MockCountdownTimerElapsedAction mockCountdownTimerElapsedAction = new MockCountdownTimerElapsedAction.Builder().Build();
            MockTimerBookEnd     mockTimerBookEnd     = new MockTimerBookEnd.Builder().Close().Build();
            MockCountdownTracker mockCountdownTracker = new MockCountdownTracker.Builder().Build();
            CountdownTimer       subject = new TestCountdownTimer(mockCountdownTimerElapsedAction, mockTimerBookEnd, mockCountdownTracker);

            //Act
            subject.Stop();

            //Assert
            mockTimerBookEnd.AssertCloseInvoked();
        }
コード例 #2
0
        public void CountdownState_ShouldReturnAccurateState()
        {
            //Arrange
            //Arrange
            MockCountdownState mockCountdownState = new MockCountdownState.Builder().Build();
            MockCountdownTimerElapsedAction mockCountdownTimerElapsedAction = new MockCountdownTimerElapsedAction.Builder().Build();
            MockTimerBookEnd     mockTimerBookEnd     = new MockTimerBookEnd.Builder().Build();
            MockCountdownTracker mockCountdownTracker = new MockCountdownTracker.Builder().CountdownState(mockCountdownState).Build();
            CountdownTimer       subject = new TestCountdownTimer(mockCountdownTimerElapsedAction, mockTimerBookEnd, mockCountdownTracker);

            //Act
            ICountdownState actual = subject.CountdownState();

            //Assert
            actual.Should().Be(mockCountdownState);
        }
コード例 #3
0
        public void Start_ShouldInvokeTimerBookEnd()
        {
            //Arrange
            //Arrange
            MockCountdownTimerElapsedAction mockCountdownTimerElapsedAction = new MockCountdownTimerElapsedAction.Builder().Build();
            MockTimerBookEnd     mockTimerBookEnd     = new MockTimerBookEnd.Builder().Start().Build();
            MockCountdownTracker mockCountdownTracker = new MockCountdownTracker.Builder().Restart().Build();
            CountdownTimer       subject = new TestCountdownTimer(mockCountdownTimerElapsedAction, mockTimerBookEnd, mockCountdownTracker);

            //Act
            subject.Start();

            //Assert
            mockCountdownTracker.AssertRestartInvoked();
            mockTimerBookEnd.AssertStartInvoked();
        }
コード例 #4
0
        public void Invoke_ShouldTriggerEvent()
        {
            //Arrange
            //Arrange
            MockCountdownTimerElapsedAction mockCountdownTimerElapsedAction = new MockCountdownTimerElapsedAction.Builder().Build();
            MockTimerBookEnd     mockTimerBookEnd     = new MockTimerBookEnd.Builder().Build();
            MockCountdownTracker mockCountdownTracker = new MockCountdownTracker.Builder().Increment().Build();
            CountdownTimer       subject = new TestCountdownTimer(mockCountdownTimerElapsedAction, mockTimerBookEnd, mockCountdownTracker);
            CountdownEvent       latch   = new CountdownEvent(1);

            subject.TimerEvent += (time, more) => latch.Signal();

            //Act
            subject.Invoke(TimerProgress.More);

            //Assert
            latch.Wait(10).Should().BeTrue();
            mockCountdownTracker.AssertIncrementInvoked();
        }