public void HasDefaultValues() { var instance = new BoilerViewModel(this.boilerService.Object, this.policyProvider.Object); instance.Heating.Should().BeFalse(); instance.Protection.Should().BeFalse(); instance.Temperature.Should().Be(0m); instance.Pressure.Should().Be(0m); instance.TargetPressure.Should().Be(0m); instance.TemperatureTrend.Should().Be(Trend.Stable); }
public void CanGetPressure() { var expected = 1.5m; this.pressure.OnNext(expected); var instance = new BoilerViewModel(this.boilerService.Object, this.policyProvider.Object); instance.Activator.Activate(); instance.Pressure.Should().Be(expected); }
public void CanGetHeating() { var expected = true; this.heating.OnNext(expected); var instance = new BoilerViewModel(this.boilerService.Object, this.policyProvider.Object); instance.Activator.Activate(); instance.Heating.Should().Be(expected); }
public void CanGetTemperatureTrend() { var instance = new BoilerViewModel(this.boilerService.Object, this.policyProvider.Object); instance.Activator.Activate(); // set twice this.temperature.OnNext(25m); this.temperature.OnNext(25m); instance.TemperatureTrend.Should().Be(Trend.Stable, "2 consecutive values, trend should be stable."); this.temperature.OnNext(26m); instance.TemperatureTrend.Should().Be(Trend.Rising, "Trend should be rising."); this.temperature.OnNext(24m); instance.TemperatureTrend.Should().Be(Trend.Falling, "Trend should be falling."); }
public async Task CanSetAndGetTargetPressure() { var expected = 1.2m; var set = 0m; this.targetPressure.Subscribe(x => set = x); var instance = new BoilerViewModel(this.boilerService.Object, this.policyProvider.Object); instance.Activator.Activate(); instance.TargetPressure = expected; instance.TargetPressure.Should().Be(expected, "TargetPressure should immediately reflect set value."); set.Should().Be(0, "TargetPressure did not debounce."); await Task.Delay(2000); set.Should().Be(expected, "TargetPressure did not propagate."); }
public void CanResetProtection() { bool canExecute = false; this.boilerService.Setup(x => x.ResetProtection(It.IsAny <CancellationToken>())).Returns(() => { this.protection.OnNext(false); return(Task.CompletedTask); }); var instance = new BoilerViewModel(this.boilerService.Object, this.policyProvider.Object); instance.Activator.Activate(); instance.ResetProtection.CanExecute.Subscribe(c => canExecute = c); this.protection.OnNext(true); instance.Protection.Should().BeTrue("Protection should be true initially."); canExecute.Should().BeTrue("Should be allowed to execute resetProtection."); instance.ResetProtection.Execute().Subscribe(); instance.Protection.Should().BeFalse("Protection should be reset now."); }
public void CanConstruct() { var instance = new BoilerViewModel(this.boilerService.Object, this.policyProvider.Object); Assert.NotNull(instance); }