Example #1
0
        public void DocumentDeleteBulk()
        {
            var size  = 10;
            var pages = TestSetup.GeneratePages(size, false);

            var repos = new ObjectiksOf();

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

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

            var list_before = repos.TypeOf <Pages>().ToList();

            Assert.IsNotNull(list_before);
            Assert.IsTrue(list_before.Count == size);

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

            var list_after = repos.TypeOf <Pages>().ToList();

            Assert.IsTrue(list_after.Count == 0);
        }
Example #2
0
        public void DocumentReader()
        {
            var pages = TestSetup.GeneratePages(10, false);

            var repos = new ObjectiksOf();

            var get_pages = repos.TypeOf <Pages>().ToList();
            var meta      = repos.GetTypeMeta <Pages>();

            //get page count..
            var numberOfRecordBefore = repos.Count <Pages>();

            //all pages remove..
            var numberOfRecordDelete = repos.TypeOf <Pages>().Delete();

            Assert.IsTrue(numberOfRecordBefore == numberOfRecordDelete);

            var numberOfRecordAfter = repos.Count <Pages>();

            //check delete success..
            Assert.IsTrue(numberOfRecordAfter == 0);

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

            var list = repos.TypeOf <Pages>().ToList();

            Assert.IsTrue(list.Count == pages.Count);

            var userPages = repos
                            .TypeOf <Pages>()
                            .KeyOf("FakeKeyOf")
                            .ToList();

            Assert.IsTrue(userPages.Count == 0);

            var keyOfTag = list[0].Tag;
            var keyOfTagNumberOfCount = list.Count(l => l.Tag == keyOfTag);

            Debug.WriteLine($"KeyOf:{keyOfTag}");

            var keyOfPages = repos.TypeOf <Pages>().KeyOf(keyOfTag).ToList();

            Assert.IsTrue(keyOfPages.Count == keyOfTagNumberOfCount);
        }
Example #3
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);
        }
Example #4
0
        public void DocumentKeyOfArray()
        {
            var repos = new ObjectiksOf();

            repos.TruncateOf <Pages>();

            var page = new Pages
            {
                WorkSpaceRef = 1,
                UserRef      = 1,
                Title        = "Test Page",
                Tag          = "Tag0",
                TagOfArray   = new string[] { "Tag1", "Tag2" }
            };

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

            var read_page = repos.TypeOf <Pages>().KeyOf("Tag2").ToList();

            Assert.IsTrue(read_page.Count == 1);
        }
Example #5
0
        public IActionResult Index()
        {
            var page = _repository
                       .TypeOf <Pages>()
                       .PrimaryOf(1)
                       .First();

            return(View(page));
        }
Example #6
0
        public void RepositoryCacheOf()
        {
            bool callBeforeCacheOf = true;

            var repos = new ObjectiksOf();

            repos.TruncateOf <Pages>();

            var pages = TestSetup.GeneratePages(5, false, true);

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

            var pageWriteCacheOf = repos.TypeOf <Pages>()
                                   .PrimaryOf(1)
                                   .CacheOf("test", callBeforeCacheOf)
                                   .First();

            var pageReadCacheOf = repos.TypeOf <Pages>()
                                  .PrimaryOf(1)
                                  .CacheOf("test", callBeforeCacheOf)
                                  .First();

            Assert.IsTrue(pageWriteCacheOf.Id == pageReadCacheOf.Id);

            var pageListWriteCacheOf = repos
                                       .TypeOf <Pages>()
                                       .CacheOf()
                                       .ToList();

            var pageListReadCacheOf = repos
                                      .TypeOf <Pages>()
                                      .CacheOf()
                                      .ToList();

            Assert.IsTrue(pageListWriteCacheOf.Count == pageListReadCacheOf.Count);
        }
Example #7
0
        public void DocumentKeyOfAfterWriterQueryExceptionTest()
        {
            var repos = new ObjectiksOf();

            repos.TruncateOf <Pages>();

            var adminPages_before_writer = repos
                                           .TypeOf <Pages>()
                                           .KeyOf("Admin")
                                           .OrderBy("Title")
                                           .Desc()
                                           .ToList();

            var pages = TestSetup.GeneratePages(10, false);

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

            try
            {
                var adminPages_after_writer = repos
                                              .TypeOf <Pages>()
                                              .KeyOf("Admin")
                                              .OrderBy("Title")
                                              .Desc()
                                              .ToList();
            }
            catch
            {
                Assert.IsTrue(false, "KeyOf value in document is empty");
            }
        }
Example #8
0
        public void DocumentWorkOfUserOfKeyOfPrimaryOf()
        {
            var repos = new ObjectiksOf();

            repos.TruncateOf <Pages>();

            var pages = TestSetup.GeneratePages(10, false, true);

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

            Assert.IsTrue(pages.Count == repos.Count <Pages>());

            var select_first  = pages[0];
            var select_second = pages[1];

            var workOfResults = repos
                                .TypeOf <Pages>()
                                .WorkOf(select_first.WorkSpaceRef)
                                .ToList();

            int workOfResultsCheckCount = pages.Count(p => p.WorkSpaceRef == select_first.WorkSpaceRef);

            Assert.IsTrue(workOfResults.Count == workOfResultsCheckCount);

            var keyOfResults = repos
                               .TypeOf <Pages>()
                               .KeyOf(select_first.Tag)
                               .ToList();

            int keyOfResultsCheckCount = pages.Count(p => p.Tag == select_first.Tag);

            Assert.IsTrue(keyOfResults.Count == keyOfResultsCheckCount);

            var primaryOfResults = repos
                                   .TypeOf <Pages>()
                                   .PrimaryOf(select_first.Id)
                                   .PrimaryOf(select_second.Id)
                                   .Any()
                                   .ToList();

            int primaryOfResultsCheckCount = pages.Count(p => p.Id == select_first.Id || p.Id == select_second.Id);

            Assert.IsTrue(primaryOfResults.Count == primaryOfResultsCheckCount);

            var primaryOfFirstResult = repos
                                       .TypeOf <Pages>()
                                       .PrimaryOf(select_first.Id)
                                       .First();

            Assert.NotNull(primaryOfFirstResult);

            var multiple = repos
                           .TypeOf <Pages>()
                           .WorkOf(select_first.WorkSpaceRef)
                           .KeyOf(select_first.Tag)
                           .PrimaryOf(select_first.Id)
                           .PrimaryOf(select_second.Id)
                           .Any()
                           .ToList();

            int multipleCheckCount = pages.Count(
                p => p.WorkSpaceRef == select_first.WorkSpaceRef &&
                p.Tag.Contains(select_first.Tag) &&
                (p.Id == select_first.Id || p.Id == select_second.Id)
                );

            Assert.IsTrue(multiple.Count == multipleCheckCount);
        }