示例#1
0
        public void Test_Serialize_WithNoValue()
        {
            // Arrange
            var testObject = new FakeObject {
                Name = "ObjectWithDefaultValue"
            };

            // Act
            var jsonString         = JsonConvert.SerializeObject(testObject);
            var deserializedObject = JsonConvert.DeserializeObject <FakeObject>(jsonString);

            // Assert
            Assert.True(!string.IsNullOrWhiteSpace(jsonString));
            Assert.Equal("ObjectWithDefaultValue", testObject.Name);
            Assert.Equal(FakeEnum.Default, testObject.FakeEnum);
            testObject.Should().BeEquivalentTo(deserializedObject);
        }