示例#1
0
        public void GetColumnsNamesForComplexTypeWithDefaultMapping()
        {
            JsonPatchMapperConfig <Document>
            .NewConfig()
            .Map(src =>
            {
                const string address = "/Address/";

                var index = src.IndexOf(address);
                if (index > -1)
                {
                    return(src.Remove(index, address.Length));
                }

                return(src);
            });

            var jsonPatch = new JsonPatchDocument <Document>();

            jsonPatch.Replace(p => p.Supplier.Address.Country, "Slovakia");
            jsonPatch.Replace(p => p.Supplier.Name, "Bob");

            var columns = jsonPatch.GetColumnsNames();

            columns.Should()
            .BeEquivalentTo("SupplierCountry", "SupplierName");
        }
示例#2
0
        public void NoMapProperties()
        {
            var config = new JsonPatchMapperConfig <Document>()
                         .Map(src =>
            {
                if (src.Contains("/Address/"))
                {
                    return(null);
                }

                return(src);
            });

            var jsonPatch = new JsonPatchDocument <Document>();

            jsonPatch.Replace(p => p.Supplier.Address.Country, "Slovakia");
            jsonPatch.Replace(p => p.Supplier.Name, "Bob");

            var columns = jsonPatch.GetColumnsNames(config);

            columns.Should()
            .BeEquivalentTo("SupplierName");
        }