Esempio n. 1
0
 public static void Init(Action <PatcheetahConfig> configure)
 {
     PatchEngineCore.Init(cfg =>
     {
         cfg.SetCustomAttributesConfigurator(new NewtonsoftAttributesConfigurator());
         configure(cfg);
     }, new NewtonsoftJsonTypesResolver());
 }
Esempio n. 2
0
        public void SimpleInitEntityCreationTest()
        {
            PatchEngineCore.Cleanup();
            PatchEngine.Init();

            var request = GetPatchRequestWithFields("Login", "LastSeenFrom");
            var entity  = request.CreateNewEntity();

            Assert.NotNull(entity);
            Assert.AreEqual(request["Login"].ToString(), entity.Login);
        }
Esempio n. 3
0
        public void RFC7396PatchingEnabledTest()
        {
            PatchEngineCore.Cleanup();
            PatchEngine.Init(cfg =>
            {
                cfg.EnableNestedPatching();
            });

            var model = new Post
            {
                Title  = "Hello!",
                Author = new Author
                {
                    GivenName  = "John",
                    FamilyName = "Doe"
                },
                Tags    = new[] { "example", "sample" },
                Content = "This will be unchanged"
            };

            var jsonPatch = @"{
                                 ""title"": ""Hello!"",
                                 ""phoneNumber"": ""+01-123-456-7890"",
                                 ""author"": {
                                            ""familyName"": null
                                 },
                                 ""tags"": [ ""example"" ]
                               }";

            var patchObject = JObject.Parse(jsonPatch).ToObject <PatchObject <Post> >();

            patchObject.ApplyTo(model);

            Assert.AreEqual("+01-123-456-7890", model.PhoneNumber);
            Assert.IsNull(model.Author.FamilyName);
            Assert.AreEqual("John", model.Author.GivenName);
            Assert.AreEqual(1, model.Tags.Length);
            Assert.AreEqual("example", model.Tags.First());
        }
Esempio n. 4
0
 public static void Init(Action <PatcheetahConfig> configure)
 {
     PatchEngineCore.Init(configure, new SystemTextJsonTypesResolver());
 }
Esempio n. 5
0
 public void SetupInternal()
 {
     PatchEngineCore.Cleanup();
     _patchRequestProvider = GetRequestProvider();
     Setup();
 }