示例#1
0
        public void formatter_withAlwaysShowNulls_showNulls()
        {
            // arrange
            var resource = new ResourceWithAlwaysShowProperty();
            // resource.Name (string) is not set and should not appear
            // resource.Number (int?) is not set, but should appear because of [AlwaysShow]

            // act
            var result = TestHelpers.Format.FormatObject(resource, _formatter);

            // assert
            result.Should().NotContain("name");
            result.Should().Contain("number");
        }
示例#2
0
        public void formatter_withIntProperty_valueIsInt()
        {
            // arrange
            var resource = new ResourceWithAlwaysShowProperty
            {
                Name   = "Pat Smith",
                Number = 42
            };
            // resource.Name (string) is set and should appear
            // resource.Number (int?) is not set, but should appear because of [AlwaysShow]

            // act
            var result = TestHelpers.Format.FormatObject(resource, _formatter);

            // assert
            result.Should().Contain("Pat Smith");
            result.Should().Contain("number");
            result.Should().Contain("42");
            result.Should().NotContain("\"42\"");
            result.Should().NotContain("'42'");
        }