예제 #1
0
        public void ShouldDelegateIncrement()
        {
            //Arrange
            Number            events            = new NumberOf(10);
            MockCounter       mockCounter       = new MockCounter.Builder().Increment().Build();
            MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build();
            CountdownTracker  subject           = new PrivateCtor <CountdownTracker>(mockCounter, events, mockCountdownTime);

            //Act
            subject.Increment();

            //Assert
            mockCounter.AssertIncrementInvoked();
        }
예제 #2
0
        public void ShouldDelegateRemaining()
        {
            //Arrange
            TimeInterval      expected          = new Seconds(100);
            MockCounter       mockCounter       = new MockCounter.Builder().Build();
            MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Remaining(expected).Build();
            CountdownTracker  subject           = new PrivateCtor <CountdownTracker>(mockCounter, new NumberOf(1), mockCountdownTime);

            //Act
            TimeInterval actual = subject.Remaining();

            //Assert
            actual.Should().Be(expected);
        }
        public void ShouldActGivenMore()
        {
            //Arrange
            TimerProgress     timeProgress                        = TimerProgress.More;
            MockMainForm      mockMainForm                        = new MockMainForm.Builder().Build();
            MockCountdownTime mockCountdownTime                   = new MockCountdownTime.Builder().Build();
            MockCountdownTimerUpdateAction nextAction             = new MockCountdownTimerUpdateAction.Builder().Act().Build();
            CountdownTimerUpdateAction_GuardAgainstNoMore subject = new CountdownTimerUpdateAction_GuardAgainstNoMore(nextAction);

            //Act
            subject.Act(mockMainForm, mockCountdownTime, timeProgress);

            //Assert
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress);
        }
예제 #4
0
        public void ShouldDelegateValue()
        {
            //Arrange
            Number            expected          = new NumberOf(1);
            Number            events            = new NumberOf(10);
            MockCounter       mockCounter       = new MockCounter.Builder().Value(expected).Build();
            MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build();
            CountdownTracker  subject           = new PrivateCtor <CountdownTracker>(mockCounter, events, mockCountdownTime);

            //Act
            Number actual = subject.Value();

            //Assert
            actual.Should().Be(expected);
        }
예제 #5
0
        public void ShouldReturnComposedCountdownState()
        {
            //Arrange
            Number            expected          = new NumberOf(10);
            Number            events            = new NumberOf(10);
            MockCounter       mockCounter       = new MockCounter.Builder().Value(expected).Build();
            MockCountdownTime mockCountdownTime = new MockCountdownTime.Builder().Build();
            CountdownTracker  subject           = new PrivateCtor <CountdownTracker>(mockCounter, events, mockCountdownTime);

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

            //Assert
            ((bool)countdownState.Finished()).Should().BeFalse();
            ((bool)countdownState.Last()).Should().BeTrue();
        }
        public void ShouldAct()
        {
            // Arrange
            TimerProgress     timeProgress            = TimerProgress.Last;
            MockMainForm      mockMainForm            = new MockMainForm.Builder().Build();
            MockCountdownTime mockCountdownTime       = new MockCountdownTime.Builder().Build();
            MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build();

            CountdownTimerUpdateAction_TimerRunning subject = new PrivateCtor <CountdownTimerUpdateAction_TimerRunning>(nextAction);

            // Act
            subject.Act(mockMainForm, mockCountdownTime, timeProgress);

            // Assert
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress);
        }
예제 #7
0
        public void ShouldAct()
        {
            // Arrange
            TimerProgress     timeProgress            = TimerProgress.Last;
            MockMainForm      mockMainForm            = new MockMainForm.Builder().Build();
            MockCountdownTime mockCountdownTime       = new MockCountdownTime.Builder().Build();
            MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build();

            ShortBreakTimerUpdateAction_TimerFinished subject = new ShortBreakTimerUpdateAction_TimerFinished(nextAction);

            // Act
            subject.Act(mockMainForm, mockCountdownTime, timeProgress);

            // Assert
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress);
        }
        public void ShouldAct()
        {
            // Arrange
            TimerProgress     timeProgress            = TimerProgress.Last;
            MockMainForm      mockMainForm            = new MockMainForm.Builder().ToTop().Build();
            MockCountdownTime mockCountdownTime       = new MockCountdownTime.Builder().Build();
            MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build();

            CountdownTimerUpdateAction_FormToTop subject = new CountdownTimerUpdateAction_FormToTop(nextAction);

            // Act
            subject.Act(mockMainForm, mockCountdownTime, timeProgress);

            // Assert
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress);
            mockMainForm.AssertToTopInvoked();
        }
예제 #9
0
        public void ShouldShowShortBreakMessage()
        {
            // Arrange
            TimerProgress     timeProgress            = TimerProgress.Last;
            MockMainForm      mockMainForm            = new MockMainForm.Builder().ShowAlert().Build();
            MockCountdownTime mockCountdownTime       = new MockCountdownTime.Builder().Build();
            MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build();

            CountdownTimerUpdateAction_ShowShortBreakOver subject = new CountdownTimerUpdateAction_ShowShortBreakOver(nextAction);

            // Act
            subject.Act(mockMainForm, mockCountdownTime, timeProgress);

            // Assert
            mockMainForm.AssertShowAlertInvokedWithCustom(text => ((string)text).Should().Be("Short Break Over!"));
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress);
        }
예제 #10
0
        public void ShouldCallActOnEachAction()
        {
            //Arrange
            MockCountdownTimerUpdateAction finished = new MockCountdownTimerUpdateAction.Builder().Act().Build();
            MockCountdownTimerUpdateAction running  = new MockCountdownTimerUpdateAction.Builder().Act().Build();
            MockMainForm      mockMainForm          = new MockMainForm.Builder().Build();
            MockCountdownTime mockCountdownTime     = new MockCountdownTime.Builder().Build();

            SessionTimerUpdateAction subject = new PrivateCtor <SessionTimerUpdateAction>(finished, running);

            //Act
            subject.Act(mockMainForm, mockCountdownTime, TimerProgress.Last);

            //Assert
            finished.AssertActInvokedWith(mockMainForm, mockCountdownTime, TimerProgress.Last);
            running.AssertActInvokedWith(mockMainForm, mockCountdownTime, TimerProgress.Last);
        }
        public void ShouldColorForeColor()
        {
            //Arrange
            TimerProgress     timeProgress                      = TimerProgress.Last;
            MockWriteColor    mockWriteColor                    = new MockWriteColor.Builder().Write().Build();
            MockMainForm      mockMainForm                      = new MockMainForm.Builder().CountDownForeColorWriter(mockWriteColor).Build();
            MockCountdownTime mockCountdownTime                 = new MockCountdownTime.Builder().Build();
            MockCountdownTimerUpdateAction nextAction           = new MockCountdownTimerUpdateAction.Builder().Act().Build();
            CountdownTimerUpdateAction_DefaultForeColor subject = new CountdownTimerUpdateAction_DefaultForeColor(nextAction);

            //Act
            subject.Act(mockMainForm, mockCountdownTime, timeProgress);

            //Assert
            //mockWriteColor.AssertWriteInvokedWithCustom();//TODO: Make sure black is written
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress);
        }
        public void ShouldWriteFormattedText()
        {
            // Arrange
            TimerProgress     timeProgress            = TimerProgress.Last;
            MockWriteText     mockWriteText           = new MockWriteText.Builder().Write().Build();
            MockMainForm      mockMainForm            = new MockMainForm.Builder().CountDownTextWriter(mockWriteText).Build();
            MockCountdownTime mockCountdownTime       = new MockCountdownTime.Builder().Remaining(new Seconds(1)).Build();
            MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build();

            CountdownTimerUpdateAction_RemainingTime subject = new CountdownTimerUpdateAction_RemainingTime(nextAction);

            //// Act
            subject.Act(mockMainForm, mockCountdownTime, timeProgress);

            // Assert
            mockWriteText.AssertWriteInvokedWithCustom(text => ((string)text).Should().Be("00:01"));
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress);
        }
예제 #13
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);
        }
예제 #14
0
        public void ShouldAct()
        {
            // Arrange
            TimerProgress     timeProgress            = TimerProgress.Last;
            MockEnabled       mockEnabled             = new MockEnabled.Builder().Enable().Build();
            MockMainForm      mockMainForm            = new MockMainForm.Builder().ShortBreakStartEnabled(mockEnabled).Build();
            MockCountdownTime mockCountdownTime       = new MockCountdownTime.Builder().Build();
            MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build();

            CountdownTimerUpdateAction_EnableShortBreakStart subject = new CountdownTimerUpdateAction_EnableShortBreakStart(nextAction);

            // Act
            subject.Act(mockMainForm, mockCountdownTime, timeProgress);

            // Assert
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress);
            mockMainForm.AssertShortBreakStartEnabledInvoked();
            mockEnabled.AssertEnableInvoked();
        }
        public void ShouldAct()
        {
            // Arrange
            TimerProgress     timeProgress            = TimerProgress.Last;
            MockVisibility    mockVisibility          = new MockVisibility.Builder().Hide().Build();
            MockMainForm      mockMainForm            = new MockMainForm.Builder().LongBreakStartVisibility(mockVisibility).Build();
            MockCountdownTime mockCountdownTime       = new MockCountdownTime.Builder().Build();
            MockCountdownTimerUpdateAction nextAction = new MockCountdownTimerUpdateAction.Builder().Act().Build();

            CountdownTimerUpdateAction_HideLongBreakStart subject = new CountdownTimerUpdateAction_HideLongBreakStart(nextAction);

            // Act
            subject.Act(mockMainForm, mockCountdownTime, timeProgress);

            // Assert
            nextAction.AssertActInvokedWith(mockMainForm, mockCountdownTime, timeProgress);
            mockMainForm.LongBreakStartVisibility();
            mockVisibility.AssertHideInvoked();
        }
        public void ShouldCallActOnShortBreakWhenCounterLessThanSessionsToBreak()
        {
            //Arrange
            MockCountdownTimerUpdateAction shortBreak = new MockCountdownTimerUpdateAction.Builder().Act().Build();
            MockCountdownTimerUpdateAction longBreak  = new MockCountdownTimerUpdateAction.Builder().Build();
            MockCounter       mockCounter             = new MockCounter.Builder().Value(new NumberOf(3)).Increment().Build();
            MockMainForm      mockMainForm            = new MockMainForm.Builder().Build();
            MockCountdownTime mockCountdownTime       = new MockCountdownTime.Builder().Build();

            SessionTimerUpdateAction_ShowNextStart subject = new PrivateCtor <SessionTimerUpdateAction_ShowNextStart>(shortBreak, longBreak, mockCounter);

            //Act
            subject.Act(mockMainForm, mockCountdownTime, TimerProgress.Last);

            //Assert
            shortBreak.AssertActInvokedWith(mockMainForm, mockCountdownTime, TimerProgress.Last);
            mockCounter.AssertValueInvoked();
            mockCounter.AssertIncrementInvoked();
        }
        public void ShouldNotActGivenLast()
        {
            //Arrange
            TimerProgress     timeProgress                        = TimerProgress.Last;
            MockMainForm      mockMainForm                        = new MockMainForm.Builder().Build();
            MockCountdownTime mockCountdownTime                   = new MockCountdownTime.Builder().Build();
            MockCountdownTimerUpdateAction nextAction             = new MockCountdownTimerUpdateAction.Builder().Build();
            CountdownTimerUpdateAction_GuardAgainstNoMore subject = new CountdownTimerUpdateAction_GuardAgainstNoMore(nextAction);

            //Act
            subject.Act(mockMainForm, mockCountdownTime, timeProgress);

            //Assert
            try
            {
                nextAction.Act(null, null, null);
                Assert.Fail("Exception expected");
            }
            catch (TestException ignored) { }
        }