public void LightSwitch_FromDynamic_ShouldReturnExpectedResult(InstalledAppInstance installedApp) { var expectedResult = new LightSwitch() { Id = Guid.NewGuid().ToString(), Label = "MyDevice", CurrentState = SwitchState.Off }; var deviceJson = $@"{{ ""deviceId"": ""{expectedResult.Id}"", ""name"": ""NAME"", ""label"": ""{expectedResult.Label}"", ""locationId"": ""{installedApp.InstalledLocation.Id}"" }}"; var statusJson = $@"{{ ""deviceId"": ""{expectedResult.Id}"", ""name"": ""NAME"", ""label"": ""{expectedResult.Label}"", ""locationId"": ""{installedApp.InstalledLocation.Id}"", ""components"" : {{ ""main"": {{ ""switch"": {{ ""switch"": {{ ""value"": ""off"" }} }} }} }} }}"; dynamic device = JObject.Parse(deviceJson); dynamic status = JObject.Parse(statusJson); var result = LightSwitch.SwitchFromDynamic(device, status); Assert.Equal(expectedResult, result); expectedResult.CurrentState = SwitchState.On; statusJson = $@"{{ ""deviceId"": ""{expectedResult.Id}"", ""name"": ""NAME"", ""label"": ""{expectedResult.Label}"", ""locationId"": ""{installedApp.InstalledLocation.Id}"", ""components"" : {{ ""main"": {{ ""switch"": {{ ""switch"": {{ ""value"": ""on"" }} }} }} }} }}"; status = JObject.Parse(statusJson); result = LightSwitch.SwitchFromDynamic(device, status); Assert.Equal(expectedResult, result); expectedResult.CurrentState = SwitchState.Unknown; statusJson = $@"{{ ""deviceId"": ""{expectedResult.Id}"", ""name"": ""NAME"", ""label"": ""{expectedResult.Label}"", ""locationId"": ""{installedApp.InstalledLocation.Id}"", ""components"" : {{ ""main"": {{ ""switch"": {{ ""switch"": {{ ""value"": ""unknown"" }} }} }} }} }}"; status = JObject.Parse(statusJson); result = LightSwitch.SwitchFromDynamic(device, status); Assert.Equal(expectedResult, result); _ = expectedResult.GetHashCode(); _ = expectedResult.ToJson(); }