当前位置: 首页>>代码示例>>C#>>正文


C# DatabaseObjectProvider.GetPreviousAndNextEntries方法代码示例

本文整理汇总了C#中Subtext.Framework.Data.DatabaseObjectProvider.GetPreviousAndNextEntries方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseObjectProvider.GetPreviousAndNextEntries方法的具体用法?C# DatabaseObjectProvider.GetPreviousAndNextEntries怎么用?C# DatabaseObjectProvider.GetPreviousAndNextEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subtext.Framework.Data.DatabaseObjectProvider的用法示例。


在下文中一共展示了DatabaseObjectProvider.GetPreviousAndNextEntries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPreviousAndNextBasedOnSyndicationDateNotEntryId

        public void GetPreviousAndNextBasedOnSyndicationDateNotEntryId()
        {
            var repository = new DatabaseObjectProvider();
            string hostname = UnitTestHelper.GenerateUniqueString();
            repository.CreateBlog("", "username", "password", hostname, string.Empty);
            UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty);
            BlogRequest.Current.Blog = repository.GetBlog(hostname, string.Empty);

            Entry previousEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body");
            Entry currentEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body");
            Entry nextEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body");

            previousEntry.IsActive = false;
            currentEntry.IsActive = false;
            nextEntry.IsActive = false;

            //Create out of order.
            int currentId = UnitTestHelper.Create(currentEntry);
            int nextId = UnitTestHelper.Create(nextEntry);
            int previousId = UnitTestHelper.Create(previousEntry);

            //Now syndicate.
            previousEntry.IsActive = true;
            var subtextContext = new Mock<ISubtextContext>();
            subtextContext.Setup(c => c.Blog).Returns(Config.CurrentBlog);
            subtextContext.Setup(c => c.Repository).Returns(repository);
            UnitTestHelper.Update(previousEntry, subtextContext.Object);
            Thread.Sleep(100);
            currentEntry.IsActive = true;
            UnitTestHelper.Update(currentEntry, subtextContext.Object);
            Thread.Sleep(100);
            nextEntry.IsActive = true;
            UnitTestHelper.Update(nextEntry, subtextContext.Object);

            Assert.IsTrue(previousId > currentId, "Ids are out of order.");

            var entries = repository.GetPreviousAndNextEntries(currentId, PostType.BlogPost);
            Assert.AreEqual(2, entries.Count, "Expected both previous and next.");
            //The first should be next because of descending sort.
            Assert.AreEqual(nextId, entries.First().Id, "The next entry does not match expectations.");
            Assert.AreEqual(previousId, entries.ElementAt(1).Id, "The previous entry does not match expectations.");
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:42,代码来源:PreviousNextTests.cs

示例2: GetPreviousAndNextEntriesReturnsBoth

        public void GetPreviousAndNextEntriesReturnsBoth()
        {
            var repository = new DatabaseObjectProvider();
            string hostname = UnitTestHelper.GenerateUniqueString();
            repository.CreateBlog("", "username", "password", hostname, string.Empty);
            UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty);
            BlogRequest.Current.Blog = repository.GetBlog(hostname, string.Empty);

            Entry previousEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
                                                                                   UnitTestHelper.GenerateUniqueString(),
                                                                                   DateTime.UtcNow.AddDays(-2));
            Entry currentEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
                                                                                  UnitTestHelper.GenerateUniqueString(),
                                                                                  DateTime.UtcNow.AddDays(-1));
            Entry nextEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
                                                                               UnitTestHelper.GenerateUniqueString(),
                                                                               DateTime.UtcNow);

            int previousId = UnitTestHelper.Create(previousEntry);
            Thread.Sleep(100);
            int currentId = UnitTestHelper.Create(currentEntry);
            Thread.Sleep(100);
            int nextId = UnitTestHelper.Create(nextEntry);

            var entries = repository.GetPreviousAndNextEntries(currentId,
                                                                                             PostType.BlogPost);
            Assert.AreEqual(2, entries.Count, "Expected both previous and next.");

            //The more recent one is next because of desceding sort.
            Assert.AreEqual(nextId, entries.First().Id, "The next entry does not match expectations.");
            Assert.AreEqual(previousId, entries.ElementAt(1).Id, "The previous entry does not match expectations.");
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:32,代码来源:PreviousNextTests.cs

示例3: GetPreviousAndNextEntriesReturnsPreviousWhenNoNextExists

        public void GetPreviousAndNextEntriesReturnsPreviousWhenNoNextExists()
        {
            string hostname = UnitTestHelper.GenerateUniqueString();
            var repository = new DatabaseObjectProvider();
            repository.CreateBlog("", "username", "password", hostname, string.Empty);
            UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty);
            BlogRequest.Current.Blog = repository.GetBlog(hostname, string.Empty);

            Entry previousEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
                                                                                   UnitTestHelper.GenerateUniqueString(),
                                                                                   DateTime.UtcNow.AddDays(-1));
            Entry currentEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
                                                                                  UnitTestHelper.GenerateUniqueString(),
                                                                                  DateTime.UtcNow);

            int previousId = UnitTestHelper.Create(previousEntry);
            int currentId = UnitTestHelper.Create(currentEntry);

            var entries = repository.GetPreviousAndNextEntries(currentId,
                                                                                             PostType.BlogPost);
            Assert.AreEqual(1, entries.Count, "Since there is no next entry, should return only 1");
            Assert.AreEqual(previousId, entries.First().Id, "The previous entry does not match expectations.");
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:23,代码来源:PreviousNextTests.cs


注:本文中的Subtext.Framework.Data.DatabaseObjectProvider.GetPreviousAndNextEntries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。