Esempio n. 1
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. 2
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. 3
0
 public void SetupInternal()
 {
     PatchEngineCore.Cleanup();
     _patchRequestProvider = GetRequestProvider();
     Setup();
 }