public void UnionRoundTrip() { Assert.Equal(LightControlCon.OnOff(true), JsonConvert.DeserializeObject <OnOff>(JsonConvert.SerializeObject(LightControlCon.OnOff(true)))); Assert.Equal(LightControlCon.OnOff(false), JsonConvert.DeserializeObject <OnOff>(JsonConvert.SerializeObject(LightControlCon.OnOff(false)))); Assert.Equal(LightControlCon.Dimmer(10), JsonConvert.DeserializeObject <Dimmer>(JsonConvert.SerializeObject(LightControlCon.Dimmer(10)))); Assert.Equal(LightControlCon.Dimmer(90), JsonConvert.DeserializeObject <Dimmer>(JsonConvert.SerializeObject(LightControlCon.Dimmer(90)))); }
public void UnionInstanceToJson() { Assert.Equal(@"{""Value"":100}", JsonConvert.SerializeObject(LightControlCon.Dimmer(100))); }
public void UnionInstanceToJson() { var json = JsonConvert.SerializeObject(LightControlCon.Dimmer(100)); Assert.Equal(@"{""Value"":100,""Tag"":2}", json); }