Esempio n. 1
0
        public void Start_executed___Stop_can_execute()
        {
            CountDownViewModel sut = this.CreateSut();

            sut.StartCommand.Execute(null);

            Assert.IsTrue(sut.StopCommand.CanExecute(null));
        }
Esempio n. 2
0
        public void Initial_State_is_Stopped()
        {
            var timerMock  = new Mock <ITimer>();
            var configMock = new Mock <IConfiguration>();
            var beeperMock = new Mock <IBeeper>();

            var sut = new CountDownViewModel(timerMock.Object, configMock.Object, beeperMock.Object);

            Assert.AreEqual(State.Stopped, sut.State);
        }
Esempio n. 3
0
        public void FontSize_gets_set()
        {
            var timerMock  = new Mock <ITimer>();
            var configMock = new Mock <IConfiguration>();
            var beeperMock = new Mock <IBeeper>();

            configMock
            .Setup(c => c.FontSize)
            .Returns(42)
            .Verifiable();

            var sut = new CountDownViewModel(timerMock.Object, configMock.Object, beeperMock.Object);

            Assert.AreEqual(42, sut.FontSize);
        }
Esempio n. 4
0
        public void TestStartCountdown()
        {
            Setup();
            //Arrange
            var settingsService = new Mock <IAppSettingsService>();
            var navigation      = new Mock <IMvxNavigationService>();

            settingsService.Setup(x => x.GetInitialTime()).Returns(10);
            //Act
            var vm = new CountDownViewModel(navigation.Object, settingsService.Object);

            vm.StartCountDown().Wait();
            //Assert
            Assert.IsTrue(vm.Timer == false);
            Assert.IsTrue(vm.ChronoTime == 0);
        }
Esempio n. 5
0
        public void Timer_ticks___Beeper_called()
        {
            _configMock
            .Setup(c => c.StartSeconds)
            .Returns(3)
            .Verifiable();

            CountDownViewModel sut = this.CreateSut();

            sut.StartCommand.Execute(null);

            _timer.OnTick();
            _timer.OnTick();
            _timer.OnTick();

            _beeperMock.Verify(b => b.Beep(2), Times.Once());
            _beeperMock.Verify(b => b.Beep(1), Times.Once());
            _beeperMock.Verify(b => b.Beep(0), Times.Once());
        }
Esempio n. 6
0
        public void Counting_down_to_0___correct_states()
        {
            _configMock
            .Setup(c => c.StartSeconds)
            .Returns(3)
            .Verifiable();

            _configMock
            .Setup(c => c.SecondsForYellow)
            .Returns(1)
            .Verifiable();

            CountDownViewModel sut = this.CreateSut();

            _configMock.Verify();

            sut.StartCommand.Execute(null);

            Assert.AreEqual(3, sut.Seconds, "state Red");
            Assert.AreEqual(State.Red, sut.State, "state Red");

            _timer.OnTick();    // 2
            _timer.OnTick();    // 1

            Assert.AreEqual(1, sut.Seconds, "state Yellow");
            Assert.AreEqual(State.Yellow, sut.State, "state Yellow");

            _timer.OnTick();    // 0

            Assert.AreEqual(0, sut.Seconds, "state Green");
            Assert.AreEqual(State.Green, sut.State, "state Green");

            _timer.OnTick();    // 3

            Assert.AreEqual(3, sut.Seconds, "state Red (restart)");
            Assert.AreEqual(State.Red, sut.State, "state Red (restart)");
        }
Esempio n. 7
0
        public void Counting_down_to_0___restarting()
        {
            _configMock
            .Setup(c => c.StartSeconds)
            .Returns(3)
            .Verifiable();

            CountDownViewModel sut = this.CreateSut();

            _configMock.Verify();

            sut.StartCommand.Execute(null);

            Assert.AreEqual(3, sut.Seconds, "after Start");
            Assert.AreEqual(State.Red, sut.State, "after Start");

            _timer.OnTick();    // 2
            _timer.OnTick();    // 1
            _timer.OnTick();    // 0
            _timer.OnTick();    // 3

            Assert.AreEqual(3, sut.Seconds, "should have restarted");
            Assert.AreEqual(State.Red, sut.State, "should have restarted");
        }
Esempio n. 8
0
        public void Init___Stop_cant_execute()
        {
            CountDownViewModel sut = this.CreateSut();

            Assert.IsFalse(sut.StopCommand.CanExecute(null));
        }