Ejemplo n.º 1
0
        public void TurnOff_OutputCorrect()
        {
            _sut.TurnOn();
            _sut.TurnOff();

            StringAssert.IsMatch("Light is turned off", _stringWriter.ToString());
        }
 public void TurnOff_WasOn_CorrectOutput()
 {
     _light.TurnOn();
     _output.ClearReceivedCalls();
     _light.TurnOff();
     _output.Received().OutputLine(Arg.Is <string>(str => str.Contains("off")));
 }
Ejemplo n.º 3
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = 1;
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                myDisplay.Clear();
                myLight.TurnOn();

                // Calculate powerLevel to percent
                int powerPercentLevel = (700 - powerLevel) * 100 / 700;
                powerPercentLevel = 100 - powerPercentLevel;

                myCooker.StartCooking(powerPercentLevel, time * 60);
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = 1;
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 4
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = 1;
                // I think this is a mistake, since on the STM
                // It doesnt say anything about a light
                // // it also fails with the integration test
                //myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                myDisplay.Clear();
                myLight.TurnOn();
                myCooker.StartCooking((powerLevel / 7), time * 60);
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = 1;
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 5
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = 1;
                myLight.TurnOff();     // er ikke på SQD eller STM
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                myDisplay.Clear();
                myLight.TurnOn();
                myCooker.StartCooking(powerLevel, time * 60);
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = 1;
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 6
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = 1;
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                myDisplay.Clear();
                myLight.TurnOn();
                myCooker.StartCooking(powerLevel, time * 60);   //Tid skal være seconds konsekvent over det hele.
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = 1;
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 7
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                ResetValues();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                myLight.TurnOn();
                // Added *1000 to turn the time variable into miliseconds, as the timer component works with that precision.
                myCooker.StartCooking(powerLevel, time * 60 * 1000);
                myState = States.COOKING;
                break;

            case States.COOKING:
                ResetValues();
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 8
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = 1;
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                //myDisplay.Clear(); It shouldn't clear Display according to UC
                myLight.TurnOn();
                myCooker.StartCooking(powerLevel, (time * 60) * 1000);
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = 1;
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 9
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = 1;
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                //Removed Display.Clear(), not in diagrams
                //myDisplay.Clear();
                myLight.TurnOn();
                //Divide powerlevel with 7 to get procentage
                myCooker.StartCooking(powerLevel / 7, time * 60);
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = 1;
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 10
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = 1;
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                myDisplay.Clear();
                myLight.TurnOn();
                myCooker.StartCooking(Convert.ToInt32(Math.Round(Convert.ToDouble(powerLevel) / 7)), time * 60000);   //rettelse
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = 1;
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 11
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = 1;
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                //myDisplay.Clear(); Slettet linje per UC definition
                myLight.TurnOn();
                myCooker.StartCooking(powerLevel, (time * 60) * 1000); //Sender sekunder, forventer millisekunder dette er rettet
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = 1;
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 12
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                ResetValues();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                myLight.TurnOn();
                myCooker.StartCooking(powerLevel, time * 60);
                myState = States.COOKING;
                break;

            case States.COOKING:
                ResetValues();
                myCooker.Stop();
                myLight.TurnOff();      //Vi indsætter nedenfor TurnOn da der skal være lys i microen når man starter den
                //myLight.TurnOn();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = TimeSpan.FromMinutes(1);
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                myDisplay.Clear();
                myLight.TurnOn();
                myCooker.StartCooking(powerLevel, time);
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = TimeSpan.FromMinutes(1);
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 14
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = 1;
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                myDisplay.Clear();
                myLight.TurnOn();
                myCooker.StartCooking((int)powerPercent, time * 1000 * 60); //Rettet til at sende PowerPercentage med.
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = 1;
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 15
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = 1;
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                /*myDisplay.Clear();*/      //Fejl ifølge sekvensdiagram og UC
                myLight.TurnOn();
                myCooker.StartCooking(powerLevel, time * 60);
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = 1;
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                powerLevel = 50;
                time       = 1;
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                //Hvorfor clearer den her? Det står ikke i sekvensdiagrammet
                myDisplay.Clear();
                myLight.TurnOn();
                myCooker.StartCooking(powerLevel, time * 60);
                myState = States.COOKING;
                break;

            case States.COOKING:
                powerLevel = 50;
                time       = 1;
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
Ejemplo n.º 17
0
        public void OnStartCancelPressed(object sender, EventArgs e)
        {
            switch (myState)
            {
            case States.SETPOWER:
                ResetValues();
                myDisplay.Clear();
                myState = States.READY;
                break;

            case States.SETTIME:
                myLight.TurnOn();
                myCooker.StartCooking(powerLevel, time * 60);
                myState = States.COOKING;
                break;

            case States.COOKING:
                ResetValues();
                myCooker.Stop();
                myLight.TurnOff();
                myDisplay.Clear();
                myState = States.READY;
                break;
            }
        }
        public void TurnOff_IsOnIsFalse_NothingHappened()
        {
            // Act:
            _lmt.TurnOff();

            // Assert:
            Assert.That(textWriter.ToString(), Is.EqualTo(string.Empty));
        }
Ejemplo n.º 19
0
        public void TurnOffIsCalledOnce()
        {
            _sut.TurnOn();
            _sut.TurnOff();
            _sut.TurnOff();

            _outputSub.ReceivedWithAnyArgs(2).OutputLine("");
        }
        public void LightOffWhileOffOutputNothingTest()
        {
            string       console;
            StringWriter stringWriter = new StringWriter();

            Console.SetOut(stringWriter);
            _sut.TurnOff();
            console = stringWriter.ToString();
            Assert.That(console, Is.EqualTo(""));
        }
 public void TurnOff_WasOn_CorrectOutput()
 {
     using (StringWriter sw = new StringWriter())
     {
         Console.SetOut(sw);
         _light.TurnOn();
         _light.TurnOff();
         string expected = $"Light is turned on{Environment.NewLine}Light is turned off{Environment.NewLine}";
         Assert.AreEqual(expected, sw.ToString());
     }
 }
        public void TurnOff_WasOn_ExpectedOutputInConsole_LightIsTurnedOff()
        {
            StringWriter stringWriter = new StringWriter();

            Console.SetOut(stringWriter);

            light.TurnOn();
            light.TurnOff();

            Assert.That(stringWriter.ToString().ToLower().Contains("off") && stringWriter.ToString().ToLower().Contains("light"));
        }
Ejemplo n.º 23
0
        public void LightOff_WhileLightOn_OutputTest()
        {
            _sut.TurnOn();
            string       Log;
            StringWriter stringWriter = new StringWriter();

            Console.SetOut(stringWriter);
            _sut.TurnOff();
            Log = stringWriter.ToString();
            Assert.That(Log, Is.EqualTo("Light is turned off\r\n"));
        }
Ejemplo n.º 24
0
 public void CookingIsDone()
 {
     switch (myState)
     {
         case States.COOKING:
             powerLevel = 50;
             time = 1;
             myDisplay.Clear();
             myLight.TurnOff();
             // Beep 3 times
             myState = States.READY;
             break;
     }
 }
Ejemplo n.º 25
0
        static void Main(string[] args)
        {
            ICreator creator = new BulbCreator();
            ILight   light   = creator.Factory();

            light.TurnOn();
            light.TurnOff();

            creator = new TubeCreator();
            light   = creator.Factory();
            light.TurnOn();
            light.TurnOff();
            Console.ReadKey();
        }
Ejemplo n.º 26
0
 public void TurnOff_lightTurnsOff_MessageSentToConsole()
 {
     uut.TurnOn();
     Console.SetOut(consoleOut);
     uut.TurnOff();
     Assert.That(consoleOut.ToString().Equals("Light is turned off\r\n"));
 }
Ejemplo n.º 27
0
 public void LightOutput_TurnOff()
 {
     _light.TurnOn();
     _light.TurnOff();
     _consoleOutput = stringWriter.ToString();
     Assert.That(_consoleOutput.Contains("Light is turned off"));
 }
Ejemplo n.º 28
0
        public void PowerTubeTurnOff_OutputLine()
        {
            _uut.TurnOn();
            _uut.TurnOff();

            _output.Received().OutputLine(Arg.Is <string>(str => str.Contains("Light is turned off")));
        }
Ejemplo n.º 29
0
        public void TestLight_TurnOff_CorrectOutput()
        {
            _light.TurnOn();
            Console.SetOut(_stringWriter);
            _light.TurnOff();

            Assert.That(_stringWriter.ToString().Contains("off") && _stringWriter.ToString().Contains("Light"));
        }
Ejemplo n.º 30
0
        public void TurnOff_LightIsTurnedOffIsWritten()
        {
            _sut.TurnOn();
            _sut.TurnOff();

            var text = _readConsole.ToString();

            Assert.That(text, Is.EqualTo("Light is turned on\r\nLight is turned off\r\n"));
        }