Example #1
0
        public void CanHideProperties()
        {
            serializer.Hide((WithPropertyAndField x) => x.Property, () => new Collection <string>());

            var input = new WithPropertyAndField
            {
                Property =
                {
                    "Lille", "Peter", "Edderkop"
                },
            };

            var jObject = JObject.FromObject(input, CreateSerializer());

            jObject.ShouldNotContainKey("Property");

            var copy = jObject.ToObject <WithPropertyAndField>(CreateSerializer());

            copy.Property.ShouldNotBe(null);
            copy.Property.ShouldBeOfType <Collection <string> >();
            copy.Property.ShouldBeEmpty();
        }