public void ConvertsDefaultLight(string str, uint expected) { var config = new HueConfiguration { DefaultLight = str }; Assert.That(config.GetDefaultLight(), Is.EqualTo(expected)); }
private async Task <HueConfiguration> GetConfiguration() { StorageFile file; try { file = await ApplicationData.Current.LocalFolder.GetFileAsync(ConfigFileName); } catch (FileNotFoundException fe) { var xorgs = new HueConfiguration { Key = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 18), ProjectName = "ProjectLight" }; file = await ApplicationData.Current.LocalFolder.CreateFileAsync(ConfigFileName, CreationCollisionOption.OpenIfExists); try { var client = new LocalHueClient(SelectedBridge); var appKey = await client.RegisterAsync(xorgs.ProjectName, xorgs.Key); client.Initialize(appKey); } catch (Exception e) { await file.DeleteAsync(); throw new RequiresUserInteractionException("User needs to press the Hue connection button", e); } await FileIO.WriteTextAsync(file, JsonConvert.SerializeObject(xorgs)); } var read = await FileIO.ReadTextAsync(file); var config = JsonConvert.DeserializeObject <HueConfiguration>(read); return(config); }