public async Task SetLightSettingsAsync(IPAddress ip, byte?on = default, byte?brightness = default, short?temperature = default, CancellationToken?cancellationToken = default) { if (on is null || brightness is null || temperature is null) { var current = await _client.GetLightAsync(ip, cancellationToken) .FirstAsync(cancellationToken ?? CancellationToken.None); on ??= current.on; brightness ??= current.brightness; temperature ??= current.temperature; } var light = new Models.MessageObject.LightObject(on !.Value, brightness !.Value, temperature !.Value); await _client.SetLightAsync(ip, light, cancellationToken); }
public async Task SetLight(byte on, byte brightness, short temperature) { var before = new Models.MessageObject.LightObject(on, brightness, temperature); await _sut.SetLightAsync(_ipAddress, before); var after = await _sut.GetLightAsync(_ipAddress).FirstAsync(); Assert.Equal(on, after.on); Assert.Equal(brightness, after.brightness); Assert.Equal(temperature, after.temperature); }