Exemplo n.º 1
0
        public async void TestStatusAfterPowerSwithOn()
        {
            await _kettleController.TogglePowerSwitch(true);

            var kettleStatus = _kettleController.KettleStatus;

            Assert.True(kettleStatus.HasWater);
            Assert.True(kettleStatus.PowerSwitch);
            Assert.True(kettleStatus.PowerLamp);
            Assert.True(kettleStatus.HeatingElement);
            Assert.True(kettleStatus.Temperature == 50);
        }
Exemplo n.º 2
0
        public async void TestPowerSwitchOffWhenNoWater()
        {
            _kettleController = GetMockedKettleController(hasWater: false);
            await _kettleController.TogglePowerSwitch(true);

            var kettleStatus = _kettleController.KettleStatus;

            Assert.False(kettleStatus.HasWater);
            Assert.False(kettleStatus.PowerSwitch);
            Assert.False(kettleStatus.PowerLamp);
            Assert.False(kettleStatus.HeatingElement);
            Assert.True(kettleStatus.Temperature == 50);
        }
Exemplo n.º 3
0
        public async void TestHeatingElementExceptionHandling()
        {
            _kettleController = GetMockedKettleController(hasFaultInHeatingElement: true);

            await _kettleController.TogglePowerSwitch(true);

            var kettleStatus = _kettleController.KettleStatus;

            Assert.True(kettleStatus.HasWater);
            Assert.False(kettleStatus.PowerSwitch);
            Assert.False(kettleStatus.PowerLamp);
            Assert.False(kettleStatus.HeatingElement);
            Assert.True(kettleStatus.Temperature == 50);
        }
Exemplo n.º 4
0
        public async void TestPowerSwitchOffAt100Degree()
        {
            _kettleController = GetMockedKettleController(temperature: 100);
            await _kettleController.TogglePowerSwitch(true);

            var kettleStatus = _kettleController.KettleStatus;

            // Re-fetch status data since the triggered event needs to refresh status data;
            if (kettleStatus.PowerSwitch)
            {
                Thread.Sleep(100);
                kettleStatus = _kettleController.KettleStatus;
            }

            Assert.True(kettleStatus.HasWater);
            Assert.False(kettleStatus.PowerSwitch);
            Assert.False(kettleStatus.PowerLamp);
            Assert.False(kettleStatus.HeatingElement);
            Assert.True(kettleStatus.Temperature == 100);
        }