Ejemplo n.º 1
0
        public void DocumentDelete()
        {
            var pages = TestSetup.GeneratePages(1, false);

            var repos = new ObjectiksOf();

            //removes
            repos.TruncateOf <Pages>();

            using (var create = repos.WriterOf <Pages>())
            {
                create.UseFormatting();
                create.AddDocument(pages[0]);
                create.SubmitChanges();
            }

            var page_after_create = repos.First <Pages>(pages[0].Id);

            Assert.IsNotNull(page_after_create);

            using (var writer = repos.WriterOf <Pages>())
            {
                writer.UseFormatting();
                writer.DeleteDocument(pages[0]);
                writer.SubmitChanges();
            }

            var page_after_delete = repos.First <Pages>(pages[0].Id);

            Assert.IsNull(page_after_delete);
        }
Ejemplo n.º 2
0
        public void DocumentUpdate()
        {
            var pages = TestSetup.GeneratePages(1, false);
            var repos = new ObjectiksOf();

            //removes
            repos.TruncateOf <Pages>();

            using (var writer = repos.WriterOf <Pages>())
            {
                writer.UseFormatting();
                writer.AddDocuments(pages);
                writer.SubmitChanges();
            }

            int pageID             = pages[0].Id;
            var page_update_before = repos.TypeOf <Pages>().PrimaryOf(pageID).First();

            Assert.NotNull(page_update_before);

            page_update_before.Title = "Updated Title";

            using (var writer = repos.WriterOf <Pages>())
            {
                writer.UseFormatting();
                writer.UpdateDocument(page_update_before);
                writer.SubmitChanges();
            }

            var page_update_after = repos.First <Pages>(pageID);

            Assert.IsTrue(page_update_before.Title == page_update_after.Title);
        }