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


C# DatabaseObjectProvider.Create方法代码示例

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


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

示例1: CanDeleteEntryMetaTag

        public void CanDeleteEntryMetaTag()
        {
            var blog = UnitTestHelper.CreateBlogAndSetupContext();
            var repository = new DatabaseObjectProvider();
            Entry entry =
                UnitTestHelper.CreateEntryInstanceForSyndication("Steven Harman", "Sweet arse entry!",
                                                                 "Giddy, giddy, goo!");
            UnitTestHelper.Create(entry);

            MetaTag tag = UnitTestHelper.BuildMetaTag("Foo, bar, zaa?", "author", null, blog.Id, entry.Id, DateTime.UtcNow);
            repository.Create(tag);

            Assert.AreEqual(1, repository.GetMetaTagsForBlog(blog, 0, 100).Count,
                            "Should be one (1) MetaTag for this blog.");
            Assert.AreEqual(1, repository.GetMetaTagsForEntry(entry, 0, 100).Count,
                            "Should be one (1) MetaTag for this entry.");

            // Now let's remove it from the data store
            Assert.IsTrue(repository.DeleteMetaTag(tag.Id), "Deleting the MetaTag failed.");

            Assert.AreEqual(0, repository.GetMetaTagsForBlog(blog, 0, 100).Count,
                            "Should be zero (0) MetaTags for this blog.");
            Assert.AreEqual(0, repository.GetMetaTagsForEntry(entry, 0, 100).Count,
                            "Should be zero (0) MetaTag for this entry.");
        }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:25,代码来源:MetaTagDeleteTests.cs

示例2: CanUpdateMetaTag

        public void CanUpdateMetaTag(string content, string name, string httpequiv)
        {
            var blog = UnitTestHelper.CreateBlogAndSetupContext();
            var repository = new DatabaseObjectProvider();
            MetaTag tag = UnitTestHelper.BuildMetaTag(content, name, httpequiv, blog.Id, null, DateTime.UtcNow);
            repository.Create(tag);

            string randomStr = UnitTestHelper.GenerateUniqueString().Left(20);
            tag.Content = content + randomStr;

            if (!string.IsNullOrEmpty(name))
            {
                tag.Name = name + randomStr;
            }

            if (!string.IsNullOrEmpty(httpequiv))
            {
                tag.HttpEquiv = httpequiv + randomStr;
            }

            Assert.IsTrue(repository.Update(tag));

            MetaTag updTag = repository.GetMetaTagsForBlog(blog, 0, 100)[0];

            ValidateMetaTags(tag, updTag);
        }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:26,代码来源:MetaTagUpdateTests.cs

示例3: CanUpdateEnclosure

        public void CanUpdateEnclosure(string title, string url, string mimetype, long size, bool addToFeed,
                                       bool showWithPost)
        {
            // Arrange
            UnitTestHelper.SetupBlog(string.Empty);
            var repository = new DatabaseObjectProvider();
            Entry e = UnitTestHelper.CreateEntryInstanceForSyndication("Simone Chiaretta", "Post for testing Enclosures",
                                                                       "Listen to my great podcast");
            int entryId = UnitTestHelper.Create(e);
            Enclosure enc = UnitTestHelper.BuildEnclosure(title, url, mimetype, entryId, size, addToFeed, showWithPost);

            repository.Create(enc);

            string randomStr = UnitTestHelper.GenerateUniqueString().Left(20);
            enc.Url = url + randomStr;

            if (!string.IsNullOrEmpty(title))
            {
                enc.Title = title + randomStr;
            }

            enc.MimeType = mimetype + randomStr;

            int randomSize = new Random().Next(10, 100);
            enc.Size = size + randomSize;

            // Act
            repository.Update(enc);

            // Assert
            Entry newEntry = repository.GetEntry(entryId, true, false);
            UnitTestHelper.AssertEnclosures(enc, newEntry.Enclosure);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:33,代码来源:EnclosureUpdateTests.cs

示例4: CanInsertNewMetaTag

        public void CanInsertNewMetaTag(string content, string name, string httpEquiv, bool withEntry, string errMsg)
        {
            blog = UnitTestHelper.CreateBlogAndSetupContext();
            var repository = new DatabaseObjectProvider();
            int? entryId = null;
            if (withEntry)
            {
                Entry e = UnitTestHelper.CreateEntryInstanceForSyndication("Steven Harman", "My Post", "Foo Bar Zaa!");
                entryId = UnitTestHelper.Create(e);
            }

            MetaTag mt = UnitTestHelper.BuildMetaTag(content, name, httpEquiv, blog.Id, entryId, DateTime.UtcNow);

            // make sure there are no meta-tags for this blog in the data store
            ICollection<MetaTag> tags = repository.GetMetaTagsForBlog(blog, 0, 100);
            Assert.AreEqual(0, tags.Count, "Should be zero MetaTags.");

            // add the meta-tag to the data store
            int tagId = repository.Create(mt);

            tags = repository.GetMetaTagsForBlog(blog, 0, 100);

            Assert.AreEqual(1, tags.Count, errMsg);

            MetaTag newTag = tags.First();

            // make sure all attributes of the meta-tag were written to the data store correctly.
            Assert.AreEqual(tagId, newTag.Id, "Wrong Id");
            Assert.AreEqual(mt.Content, newTag.Content, "Wrong content");
            Assert.AreEqual(mt.Name, newTag.Name, "wrong name attribute");
            Assert.AreEqual(mt.HttpEquiv, newTag.HttpEquiv, "Wrong http-equiv attriubte");
            Assert.AreEqual(mt.BlogId, newTag.BlogId, "Wrong blogId");
            Assert.AreEqual(mt.EntryId, newTag.EntryId, "Wrong entryId");
            Assert.AreEqual(mt.DateCreatedUtc.Date, newTag.DateCreatedUtc.Date, "Wrong created date");
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:35,代码来源:MetaTagInsertTests.cs

示例5: Create_WithFeedbackItem_SetsDateCreatedAndModifiedToUtcNow

        public void Create_WithFeedbackItem_SetsDateCreatedAndModifiedToUtcNow()
        {
            // Arrange
            var now = DateTime.UtcNow;
            var sps = new Mock<StoredProcedures>("test");
            sps.Setup(s => s.InsertFeedback(It.IsAny<string>(),
                It.IsAny<string>(),
                It.IsAny<int>(),
                It.IsAny<int?>(),
                It.IsAny<string>(),
                It.IsAny<bool>(),
                It.IsAny<string>(),
                It.IsAny<string>(),
                It.IsAny<int>(),
                It.IsAny<int>(),
                It.IsAny<bool>(),
                It.IsAny<string>(),
                It.IsAny<string>(),
                It.IsAny<string>(),
                It.IsAny<string>(),
                It.IsAny<DateTime>(),
                It.IsAny<DateTime?>(),
                It.IsAny<DateTime>()));
            var repository = new DatabaseObjectProvider(blogId: 1, procedures: sps.Object);
            var feedback = new FeedbackItem(FeedbackType.Comment) { Body = "blah" };

            // Act
            repository.Create(feedback);

            // Assert
            Assert.GreaterEqualThan(DateTime.UtcNow, feedback.DateCreatedUtc);
            Assert.GreaterEqualThan(DateTime.UtcNow, feedback.DateModifiedUtc);
            Assert.GreaterEqualThan(feedback.DateCreatedUtc, now);
            Assert.GreaterEqualThan(feedback.DateModifiedUtc, now);
        }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:35,代码来源:FeedbackRepositoryTests.cs

示例6: Create_WithInvalidEntry_ThrowsArgumentException

        public void Create_WithInvalidEntry_ThrowsArgumentException()
        {
            // arrange
            var repository = new DatabaseObjectProvider();
            var enclosure = new Enclosure { EntryId = 0 };

            // act, assert
            Assert.IsFalse(enclosure.IsValid);
            UnitTestHelper.AssertThrows<ArgumentException>(() => repository.Create(enclosure));
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:10,代码来源:EnclosureInsertTests.cs

示例7: CanRemoveHttpEquivAndAddName

        public void CanRemoveHttpEquivAndAddName()
        {
            var blog = UnitTestHelper.CreateBlogAndSetupContext();
            var repository = new DatabaseObjectProvider();
            MetaTag tag = UnitTestHelper.BuildMetaTag("Still nothing to see here.", null, "expires", blog.Id, null, DateTime.UtcNow);
            repository.Create(tag);

            tag.HttpEquiv = null;
            tag.Name = "author";
            tag.Content = "Steve-o-rino!";

            repository.Update(tag);

            ValidateMetaTags(tag, repository.GetMetaTagsForBlog(blog, 0, 100)[0]);
        }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:15,代码来源:MetaTagUpdateTests.cs

示例8: CanRemoveNameAndAddHttpEquiv

        public void CanRemoveNameAndAddHttpEquiv()
        {
            var blog = UnitTestHelper.CreateBlogAndSetupContext();
            var repository = new DatabaseObjectProvider();
            MetaTag tag = UnitTestHelper.BuildMetaTag("Nothing to see here.", "description", null, blog.Id, null,
                                                      DateTime.UtcNow);
            repository.Create(tag);

            tag.HttpEquiv = "cache-control";
            tag.Name = null;
            tag.Content = "no-cache";

            repository.Update(tag);

            ValidateMetaTags(tag, repository.GetMetaTagsForBlog(blog, 0, 100)[0]);
        }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:16,代码来源:MetaTagUpdateTests.cs

示例9: CanDeleteBlogMetaTag

        public void CanDeleteBlogMetaTag()
        {
            var blog = UnitTestHelper.CreateBlogAndSetupContext();
            var repository = new DatabaseObjectProvider();
            MetaTag tag =
                UnitTestHelper.BuildMetaTag("Steve Harman likes to delete stuff!", "description", null, blog.Id, null,
                                            DateTime.UtcNow);
            repository.Create(tag);
            Assert.AreEqual(1, repository.GetMetaTagsForBlog(blog, 0, 100).Count,
                            "Should be one (1) MetaTag for this blog.");

            // Now let's remove it from the data store
            Assert.IsTrue(repository.DeleteMetaTag(tag.Id), "Deleting the MetaTag failed.");

            Assert.AreEqual(0, repository.GetMetaTagsForBlog(blog, 0, 100).Count,
                            "Should be zero (0) MetaTags for this blog.");
        }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:17,代码来源:MetaTagDeleteTests.cs

示例10: CanInsertEnclosure

        public void CanInsertEnclosure(string title, string url, string mimetype, long size, bool addToFeed,
                                       bool showWithPost, string errMsg)
        {
            UnitTestHelper.SetupBlog();
            var repository = new DatabaseObjectProvider();
            Entry e = UnitTestHelper.CreateEntryInstanceForSyndication("Simone Chiaretta", "Post for testing Enclosures",
                                                                       "Listen to my great podcast");
            int entryId = UnitTestHelper.Create(e);
            Enclosure enc = UnitTestHelper.BuildEnclosure(title, url, mimetype, entryId, size, addToFeed, showWithPost);

            repository.Create(enc);

            Entry newEntry = repository.GetEntry(entryId, true, false);

            Assert.IsNotNull(newEntry.Enclosure, errMsg);

            UnitTestHelper.AssertEnclosures(enc, newEntry.Enclosure);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:18,代码来源:EnclosureInsertTests.cs

示例11: GetEntriesByCategoryIncludesEnclosure

        public void GetEntriesByCategoryIncludesEnclosure()
        {
            //Create Category
            int blogId = Config.CurrentBlog.Id;
            int categoryId = UnitTestHelper.CreateCategory(blogId, "Test Category");

            //Create some entries.
            Entry entryZero = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-zero", "body-zero");
            Thread.Sleep(100);
            Entry entryOne = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-one", "body-one");
            Thread.Sleep(100);
            Entry entryTwo = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-two", "body-two");

            //Associate Category
            entryZero.Categories.Add("Test Category");
            entryOne.Categories.Add("Test Category");
            entryTwo.Categories.Add("Test Category");

            //Persist entries.
            UnitTestHelper.Create(entryZero);
            UnitTestHelper.Create(entryOne);
            UnitTestHelper.Create(entryTwo);
            var repository = new DatabaseObjectProvider();

            //Add Enclosure
            Enclosure enc = UnitTestHelper.BuildEnclosure("Nothing to see here.", "httP://blablabla.com", "audio/mp3",
                                                          entryZero.Id, 12345678, true, true);
            repository.Create(enc);

            //Get Entries
            ICollection<Entry> entries = repository.GetEntriesByCategory(3, categoryId, true);

            //Test outcome
            Assert.AreEqual(3, entries.Count, "Expected to find three entries.");

            Assert.AreEqual(entries.First().Id, entryTwo.Id, "Ordering is off.");
            Assert.AreEqual(entries.ElementAt(1).Id, entryOne.Id, "Ordering is off.");
            Assert.AreEqual(entries.ElementAt(2).Id, entryZero.Id, "Ordering is off.");

            Assert.IsNull(entries.First().Enclosure, "Entry should not have enclosure.");
            Assert.IsNull(entries.ElementAt(1).Enclosure, "Entry should not have enclosure.");
            Assert.IsNotNull(entries.ElementAt(2).Enclosure, "Entry should have enclosure.");
            UnitTestHelper.AssertEnclosures(enc, entries.ElementAt(2).Enclosure);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:44,代码来源:EntriesGetTests.cs

示例12: CanDeleteEnclosure

        public void CanDeleteEnclosure()
        {
            Blog blog = UnitTestHelper.CreateBlogAndSetupContext();
            var repository = new DatabaseObjectProvider();
            Entry e = UnitTestHelper.CreateEntryInstanceForSyndication("Simone Chiaretta", "Post for testing Enclosures",
                                                                       "Listen to my great podcast");
            int entryId = UnitTestHelper.Create(e);

            Enclosure enc = UnitTestHelper.BuildEnclosure("Nothing to see here.", "httP://blablabla.com", "audio/mp3",
                                                          entryId, 12345678, true, true);
            repository.Create(enc);

            Entry newEntry = repository.GetEntry(entryId, true, false);

            Assert.IsNotNull(newEntry.Enclosure, "Did not create enclosure.");

            repository.DeleteEnclosure(enc.Id);

            Entry newEntry1 = repository.GetEntry(entryId, true, false);

            Assert.IsNull(newEntry1.Enclosure, "Did not delete enclosure.");
        }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:22,代码来源:EncosureDeleteTests.cs

示例13: GetPostsByMonthReturnsDaysWithEnclosure

        public void GetPostsByMonthReturnsDaysWithEnclosure()
        {
            //Create some entries.
            Entry entryZero = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-zero", "body-zero");
            Thread.Sleep(100);
            Entry entryOne = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-one", "body-one");
            Thread.Sleep(100);
            Entry entryTwo = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-two", "body-two");
            Thread.Sleep(100);
            Entry entryThree = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-two", "body-two");
            entryThree.DateCreatedUtc = DateTime.UtcNow.AddDays(1);

            //Persist entries.
            UnitTestHelper.Create(entryZero);
            UnitTestHelper.Create(entryOne);
            UnitTestHelper.Create(entryTwo);
            UnitTestHelper.Create(entryThree);
            var repository = new DatabaseObjectProvider();

            //Add Enclosure
            Enclosure enc = UnitTestHelper.BuildEnclosure("Nothing to see here.", "httP://blablabla.com", "audio/mp3",
                                                          entryZero.Id, 12345678, true, true);
            repository.Create(enc);

            //Get EntryDay
            //ICollection<EntryDay> entryList = Entries.GetPostsByMonth(DateTime.UtcNow.Month, DateTime.Now.Year);

            //EntryDay[] days = new EntryDay[2];
            //entryList.CopyTo(days, 0);

            ////Test outcome
            //Assert.AreEqual(2, entryList.Count, "Expected to find two days.");

            //EntryDay entries = days[1];
            //Assert.AreEqual(3, entries.Count, "Expected to find three entries.");

            //Assert.AreEqual(entries.First().Id, entryTwo.Id, "Ordering is off.");
            //Assert.AreEqual(entries.ElementAt(1).Id, entryOne.Id, "Ordering is off.");
            //Assert.AreEqual(entries.ElementAt(2).Id, entryZero.Id, "Ordering is off.");

            //Assert.IsNull(entries.First().Enclosure, "Entry should not have enclosure.");
            //Assert.IsNull(entries.ElementAt(1).Enclosure, "Entry should not have enclosure.");
            //Assert.IsNotNull(entries.ElementAt(2).Enclosure, "Entry should have enclosure.");
            //UnitTestHelper.AssertEnclosures(enc, entries.ElementAt(2).Enclosure);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:45,代码来源:EntryDayGetTests.cs

示例14: GetPostsByCategoryIDReturnsDaysWithEnclosure

        public void GetPostsByCategoryIDReturnsDaysWithEnclosure()
        {
            //Create Category
            int blogId = Config.CurrentBlog.Id;
            int categoryId = UnitTestHelper.CreateCategory(blogId, "Test Category");

            //Create four entries.
            Entry entryZero = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-zero", "body-zero");
            entryZero.DatePublishedUtc = DateTime.UtcNow.AddDays(-1);
            Thread.Sleep(100);
            Entry entryOne = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-one", "body-one");
            entryOne.DatePublishedUtc = DateTime.UtcNow.AddDays(-1);
            Thread.Sleep(100);
            Entry entryTwo = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-two", "body-two");
            entryTwo.DatePublishedUtc = DateTime.UtcNow.AddDays(-1);
            Thread.Sleep(100);
            Entry entryThree = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-three", "body-two");
            entryThree.DatePublishedUtc = DateTime.UtcNow;

            //Associate Category
            entryZero.Categories.Add("Test Category");
            entryOne.Categories.Add("Test Category");
            entryThree.Categories.Add("Test Category");

            //Persist entries.
            UnitTestHelper.Create(entryZero);
            UnitTestHelper.Create(entryOne);
            UnitTestHelper.Create(entryTwo);
            UnitTestHelper.Create(entryThree);
            var repository = new DatabaseObjectProvider();

            //Add Enclosure
            Enclosure enc = UnitTestHelper.BuildEnclosure("Nothing to see here.", "httP://blablabla.com", "audio/mp3",
                                                          entryZero.Id, 12345678, true, true);
            repository.Create(enc);

            //Get EntryDay
            ICollection<EntryDay> entryList = repository.GetBlogPostsByCategoryGroupedByDay(10, categoryId).ToList();

            var days = new EntryDay[2];
            entryList.CopyTo(days, 0);

            //Test outcome
            Assert.AreEqual(2, entryList.Count, "Expected to find two days.");

            EntryDay entries = days[1];
            Assert.AreEqual(2, entries.Count, "Expected to find two entries.");

            Assert.AreEqual(entries.First().Id, entryOne.Id, "Ordering is off.");
            Assert.AreEqual(entries.ElementAt(1).Id, entryZero.Id, "Ordering is off.");

            Assert.IsNull(entries.First().Enclosure, "Entry should not have enclosure.");
            Assert.IsNotNull(entries.ElementAt(1).Enclosure, "Entry should have enclosure.");
            UnitTestHelper.AssertEnclosures(enc, entries.ElementAt(1).Enclosure);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:55,代码来源:EntryDayGetTests.cs

示例15: GetHomePageEntriesReturnsDaysWithEnclosure

        public void GetHomePageEntriesReturnsDaysWithEnclosure()
        {
            //Create some entries.
            Entry entryZero = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-zero", "body-zero");
            entryZero.DatePublishedUtc = DateTime.UtcNow.AddDays(-1);
            entryZero.IsActive = entryZero.IncludeInMainSyndication = true;
            Thread.Sleep(100);
            Entry entryOne = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-one", "body-one");
            entryOne.DatePublishedUtc = DateTime.UtcNow.AddDays(-1);
            entryOne.IsActive = entryOne.IncludeInMainSyndication = true;
            Thread.Sleep(100);
            Entry entryTwo = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-two", "body-two");
            entryTwo.DisplayOnHomePage = false;
            Thread.Sleep(100);
            Entry entryThree = UnitTestHelper.CreateEntryInstanceForSyndication("me", "title-two", "body-two");
            entryThree.IsActive = entryThree.IncludeInMainSyndication = true;

            //Persist entries.
            UnitTestHelper.Create(entryZero);
            UnitTestHelper.Create(entryOne);
            UnitTestHelper.Create(entryTwo);
            UnitTestHelper.Create(entryThree);
            var repository = new DatabaseObjectProvider();

            //Add Enclosure
            Enclosure enc = UnitTestHelper.BuildEnclosure("Nothing to see here.", "httP://blablabla.com", "audio/mp3",
                                                          entryZero.Id, 12345678, true, true);
            repository.Create(enc);

            //Get EntryDay
            ICollection<EntryDay> entryList = repository.GetBlogPostsForHomePage(10, PostConfig.DisplayOnHomepage | PostConfig.IsActive).ToList();

            var days = new EntryDay[2];
            entryList.CopyTo(days, 0);

            //Test outcome
            Assert.AreEqual(2, entryList.Count, "Expected to find two days.");

            EntryDay entries = days[1];
            Assert.AreEqual(2, entries.Count, "Expected to find two entries.");

            Assert.AreEqual(entries.First().Id, entryOne.Id, "Ordering is off.");
            Assert.AreEqual(entries.ElementAt(1).Id, entryZero.Id, "Ordering is off.");

            Assert.IsNull(entries.First().Enclosure, "Entry should not have enclosure.");
            Assert.IsNotNull(entries.ElementAt(1).Enclosure, "Entry should have enclosure.");
            UnitTestHelper.AssertEnclosures(enc, entries.ElementAt(1).Enclosure);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:48,代码来源:EntryDayGetTests.cs


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