示例#1
0
 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))));
 }
示例#2
0
 public void UnionInstanceToJson()
 {
     Assert.Equal(@"{""Value"":100}", JsonConvert.SerializeObject(LightControlCon.Dimmer(100)));
 }
示例#3
0
        public void UnionInstanceToJson()
        {
            var json = JsonConvert.SerializeObject(LightControlCon.Dimmer(100));

            Assert.Equal(@"{""Value"":100,""Tag"":2}", json);
        }