Exemplo n.º 1
0
        public void TurnOff_IsOnIsFalse_OutputNotCalled()
        {
            // Act:
            _tlm.TurnOff();

            // Assert:
            Assert.That(_textWriter.ToString(), Is.Empty);
        }
Exemplo n.º 2
0
        public void TurnOffOutputNothingTest()
        {
            string       console;
            StringWriter stringWriter = new StringWriter();

            _sut.TurnOff();
            console = stringWriter.ToString();
            Assert.That(console, Is.EqualTo(""));
        }
Exemplo n.º 3
0
        public void PowerTubeIsOn_TurnOffCorrect()
        {
            int power = 50;

            _sut.TurnOn(power);
            _sut.TurnOff();

            StringAssert.IsMatch($"PowerTube works with { power } %\r\nPowerTube turned off", _stringWriter.ToString());
        }
 public void TurnOff_WasOn_CorrectOutput()
 {
     using (StringWriter sw = new StringWriter())
     {
         Console.SetOut(sw);
         _powerTube.TurnOn(50);
         _powerTube.TurnOff();
         string expected = $"PowerTube works with 50{Environment.NewLine}PowerTube turned off{Environment.NewLine}";
         Assert.AreEqual(expected, sw.ToString());
     }
 }
Exemplo n.º 5
0
        public void TurnOff_WasOn_ExpectedOutputInConsole_Off()
        {
            StringWriter stringWriter = new StringWriter();

            Console.SetOut(stringWriter);

            powerTube.TurnOn(300);
            powerTube.TurnOff();

            Assert.That(stringWriter.ToString().ToLower().Contains("off"));
        }
Exemplo n.º 6
0
        public void TurnOff_ActivePowerTube_TurnsOff()
        {
            // Arrange
            powertube.TurnOn(50);
            StringWriter output = new();

            Console.SetOut(output);

            //Act
            powertube.TurnOff();

            //Assert
            string expectedOutput = "PowerTube turned off\r\n";

            Assert.That(output.ToString(), Is.EqualTo(expectedOutput));
        }
        public void PowerTubeTurnOff_OutputLine()
        {
            _uut.TurnOn(50);
            _uut.TurnOff();

            _output.Received().OutputLine(Arg.Is <string>(str => str.Contains("PowerTube turned off")));
        }
Exemplo n.º 8
0
 public void PowerTubeOutput_TurnOff()
 {
     _powertube.TurnOn(100);
     _powertube.TurnOff();
     _consoleOutput = stringWriter.ToString();
     Assert.That(_consoleOutput.Contains("PowerTube turned off"));
 }
Exemplo n.º 9
0
 public void TurnOnAndOffPowerTubeIsCalled()
 {
     _sut.TurnOn(50);
     _sut.TurnOff();
     _outputSub.Received(1).OutputLine($"PowerTube works with {50} W");
     _outputSub.Received(1).OutputLine($"PowerTube turned off");
 }
Exemplo n.º 10
0
 public void TurnOff_powerOff_MessageSentToConsole()
 {
     uut.TurnOn(50);
     Console.SetOut(consoleOut);
     uut.TurnOff();
     Assert.That(consoleOut.ToString().Equals("PowerTube turned off\r\n"));
 }
Exemplo n.º 11
0
        public void Ready_2PowerButton_PowerIs100()
        {
            powerTube.TurnOn(100);
            powerTube.TurnOff();

            Assert.That(stringWriter.ToString().Contains("PowerTube works with 100"));
        }
Exemplo n.º 12
0
        public void TestPowertube_TurnOff_IsOnIsTrue_CorrectOutput()
        {
            Console.SetOut(_stringWriter);
            _powerTube.TurnOn(50);

            _powerTube.TurnOff();
            Assert.That(_stringWriter.ToString().Contains("PowerTube turned off"));
        }
Exemplo n.º 13
0
        public void TurnOff_PowerIsTurnedOffIsWritten(int power)
        {
            _sut.TurnOn(power);
            _sut.TurnOff();

            var text = _readConsole.ToString();

            Assert.That(text, Is.EqualTo($"PowerTube works with {power}\r\nPowerTube turned off\r\n"));
        }
Exemplo n.º 14
0
        public void CookControllerTest(int power, int seconds)
        {
            _uut.StartCooking(power, seconds);
            Thread.Sleep(100 + 1000 * seconds);

            Received.InOrder(() =>
            {
                _powerTube.TurnOn(power);

                for (int i = seconds - 1; i >= 0; i--)
                {
                    _display.ShowTime(i / 60, i % 60);
                }

                _powerTube.TurnOff();
                _ui.CookingIsDone();
            });
        }
Exemplo n.º 15
0
        public void TurnOff_IsOn_OutputsTurnedOff()
        {
            input.TurnOn(50);
            sw = new StringWriter();
            Console.SetOut(sw);
            input.TurnOff();
            var expected = $"PowerTube turned off{Environment.NewLine}";

            Assert.That(expected, Is.EqualTo(sw.ToString()));
        }
 public void DoorOpenedWhileCooking_TurnOffPowerTubeAndTimer()
 {
     _powerButton.Press();
     _timeButton.Press();
     _startCancelButton.Press();
     _door.Open();
     Received.InOrder(() =>
     {
         _powerTube.TurnOff();
         _timer.Stop();
     });
 }
        public void TestPowertube_OutputTurnOff()
        {
            _powerTube.TurnOn(50);

            Console.SetOut(_writer);

            _powerTube.TurnOff();

            string ConsoleOutput = _writer.ToString();

            Assert.That(ConsoleOutput, Is.EqualTo("PowerTube turned off\r\n"));
        }
        public void PowerTube_TurnOn_OutputTurnOff()
        {
            string       msgOut;
            StringWriter stringWriter = new StringWriter();

            Console.SetOut(stringWriter);

            _sut.TurnOn(50);
            _sut.TurnOff();

            msgOut = stringWriter.ToString();
            Assert.That(msgOut, Is.EqualTo("PowerTube works with 50 W\r\nPowerTube turned off\r\n"));
        }
 public void StartCancelPressedWhileCookinng_TurnOffPowerTubeAndTimer()
 {
     _powerButton.Press();
     _timeButton.Press();
     _startCancelButton.Press();
     _startCancelButton.Press();
     Received.InOrder(() =>
     {
         _timer.Start(60);
         _powerTube.TurnOn(50);
         _powerTube.TurnOff();
         _timer.Stop();
     });
 }
        public void TurnOffOutputIsCorrect()
        {
            using (StringWriter stringWriter = new StringWriter())
            {
                //Arrange
                Console.SetOut(stringWriter);
                string expectedOutput = $"PowerTube works with 50\r\nPowerTube turned off\r\n";
                _sut.TurnOn(50);

                //Act
                _sut.TurnOff();

                //Assert
                Assert.AreEqual(expectedOutput, stringWriter.ToString());
            }
        }
Exemplo n.º 21
0
        public void PowerTubeToOutputTest_TurnOff_OutputLine()
        {
            //assign
            //Used to redirect Console output
            var sw = new StringWriter();

            _powerTube.TurnOn(50); // go to turned on state
            Console.SetOut(sw);    //Redirect


            //act
            _powerTube.TurnOff();

            //assert
            Assert.That(sw.ToString(), Is.EqualTo("PowerTube turned off\r\n"));
        }
Exemplo n.º 22
0
 public void Stop()
 {
     myPowerTube.TurnOff();
 }
Exemplo n.º 23
0
 public void Stop()
 {
     isCooking = false;
     myPowerTube.TurnOff();
     myTimer.Stop();
 }
Exemplo n.º 24
0
 public void TurnOff_DisplaysOff()
 {
     _powertube.TurnOn(50);
     _powertube.TurnOff();
     _output.OutputLine(Arg.Is <string>(str => str.Contains("off")));
 }
Exemplo n.º 25
0
 public void PowerTube_TurnOff_AlreadyOn_OutputIsCorrect()
 {
     _powerTube.TurnOn(45);
     _powerTube.TurnOff();
     _output.Received(1).OutputLine("PowerTube turned off");
 }
 public void PowerTubeTurnOff(int power)
 {
     powerTube.TurnOn(power);
     powerTube.TurnOff();
     Assert.That(stringWriter.ToString().Contains("PowerTube turned off"));
 }
Exemplo n.º 27
0
 public void OnTurnOff_IfNotTurnedOn_NoMessageIsMade()
 {
     _powerTube.TurnOff();
 }