public async Task StartHeatingMode_CurrentRoomTemperatureHigherThanTarget_AirConditionerSwitchesToStandBy() { // Arrange. IAirConditioner airConditioner = new FakeAirConditioner(LoggerFactory.CreateLogger <IAirConditioner>(), 30, secondsToTemperatureChange: 0); airConditioner.PowerOn(); // Act. await airConditioner.StartHeatingMode(20); // Assert airConditioner.RoomTemperature.Should().Be(30); airConditioner.CurrentMode.Should().Be(AirConditionerMode.StandBy); }
public async Task StartHeatingMode_TargetTemperatureHigherThanMax_AirConditionerHeatsRoomToMax() { // Arrange. IAirConditioner airConditioner = new FakeAirConditioner(LoggerFactory.CreateLogger <IAirConditioner>(), 40 - 1, secondsToTemperatureChange: 0); airConditioner.PowerOn(); // Act. await airConditioner.StartHeatingMode(airConditioner.MaxTemperature + 1); // Assert await Task.Delay(TimeSpan.FromSeconds(1)); airConditioner.RoomTemperature.Should().Be(airConditioner.MaxTemperature); airConditioner.CurrentMode.Should().Be(AirConditionerMode.StandBy); }
public async Task PowerOff_PowerOffDuringRunningTask_TaskShouldBeStopped() { // Arrange. int initialTemperature = 20; IAirConditioner airConditioner = new FakeAirConditioner(LoggerFactory.CreateLogger <IAirConditioner>(), initialTemperature, secondsToTemperatureChange: 1); airConditioner.PowerOn(); // Act. await airConditioner.StartHeatingMode(airConditioner.MaxTemperature); await Task.Delay(TimeSpan.FromSeconds(1)); airConditioner.RoomTemperature.Should().BeGreaterThan(initialTemperature); airConditioner.CurrentMode.Should().Be(AirConditionerMode.Heating); airConditioner.PowerOff(); // Assert airConditioner.RoomTemperature.Should().BeLessThan(airConditioner.MaxTemperature); airConditioner.CurrentMode.Should().Be(AirConditionerMode.StandBy); }