コード例 #1
0
 public void EnumDescription_ReadJson_JsonProperty_NotDefined()
 {
     try
     {
         TestConverterJsonPropertyNotDefined testConverter = new TestConverterJsonPropertyNotDefined {
             Id = Guid.NewGuid(), TypeMessage = TypeMessageJsonPropertyNotDefined.UNPROCESSED
         };
         string json = JsonConvert.SerializeObject(testConverter);
         Assert.IsTrue(json.Contains("UNPROCESSED"));
         TestConverter testConverterDeserialize = JsonConvert.DeserializeObject <TestConverter>(json);
     }
     catch (Exception ex)
     {
         Assert.IsTrue(ex.Message == "JsonProperty is not defined.\r\nParameter name: TypeMessage");
     }
 }
コード例 #2
0
        public void EnumDescription_ProcessedMessage()
        {
            try
            {
                TestConverter testConverter = new TestConverter {
                    Id = Guid.NewGuid(), TypeMessage = TypeMessage.PROCESSED
                };

                string json = JsonConvert.SerializeObject(testConverter);

                Assert.IsTrue(json.Contains("Processed Message"));

                TestConverter testConverterDeserialize = JsonConvert.DeserializeObject <TestConverter>(json);

                Assert.IsTrue(testConverterDeserialize.TypeMessage == TypeMessage.PROCESSED);
            }
            catch
            {
                Assert.Fail();
            }
        }