public void HassStateShouldConvertCorrectEntityState() { // ARRANGE var doc = JsonDocument.Parse("{\"str\": \"attr3value\"}"); var prop = doc.RootElement.GetProperty("str"); var hassState = new HassState { EntityId = "light.fake", Attributes = new Dictionary <string, object> { ["attr1"] = "attr1value", ["attr2"] = "attr2value", ["attr3"] = prop }, LastChanged = new DateTime(2000, 1, 1, 1, 1, 1), LastUpdated = new DateTime(2000, 1, 1, 1, 1, 2), Context = new HassContext { Id = "idguid", ParentId = "parentidguid", UserId = "useridguid" } }; // ACT var entityState = hassState.Map(); // ASSERT Assert.Equal("light.fake", entityState.EntityId); Assert.Equal(new DateTime(2000, 1, 1, 1, 1, 1), entityState.LastChanged); Assert.Equal(new DateTime(2000, 1, 1, 1, 1, 2), entityState.LastUpdated); Assert.NotNull(entityState.Attribute); Assert.Equal("attr1value", entityState?.Attribute?.attr1); Assert.Equal("attr2value", entityState?.Attribute?.attr2); Assert.Equal("attr3value", entityState?.Attribute?.attr3); Assert.NotNull(entityState?.Context); Assert.Equal("idguid", hassState.Context.Id); Assert.Equal("parentidguid", hassState.Context.ParentId); Assert.Equal("useridguid", hassState.Context.UserId); }