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


C# Context.CreateForum方法代码示例

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


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

示例1: ForumCreate_WithoutUid_ThrowsError

        public void ForumCreate_WithoutUid_ThrowsError()
        {
            var commentForum = new Forum{Id = ""};
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var site = mocks.DynamicMock<ISite>();
            var cacheManager = mocks.DynamicMock<ICacheManager>();
            //readerCreator.Stub(x => x.CreateDnaDataReader("getmoderationclasslist")).Return(reader);

           
            mocks.ReplayAll();

            var context = new Context(null, readerCreator, cacheManager, null);
            

            try
            {
                context.CreateForum(commentForum, site);
                throw new Exception("Error not thrown within code");
            }
            catch (ApiException ex)
            {
                Assert.AreEqual("Forum uid is empty, null or exceeds 255 characters.", ex.Message);
                Assert.AreEqual(ErrorType.InvalidForumUid, ex.type);               
            }
            readerCreator.AssertWasNotCalled(x => x.CreateDnaDataReader("commentforumcreate"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:26,代码来源:ContextTest.cs

示例2: ForumCreate_WithWithNotSignedIn_ReturnsOK

        public void ForumCreate_WithWithNotSignedIn_ReturnsOK()
        {
            var commentForum = new Forum
            {
                Id = "".PadRight(10, 'a'),
                ParentUri = "http://www.bbc.co.uk/dna",
                Title = "title",
                allowNotSignedInCommenting = true
            };
            var siteId = 1;
            var forumId = 10;

            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var reader = mocks.DynamicMock<IDnaDataReader>();
            var site = mocks.DynamicMock<ISite>();
            site.Stub(x => x.SiteID).Return(siteId);
            var cacheManager = mocks.DynamicMock<ICacheManager>();
            var siteList = mocks.DynamicMock<ISiteList>();
            siteList.Stub(x => x.GetSiteOptionValueBool(siteId, "CommentForum", "AllowNotSignedInCommenting")).Return(true);
            readerCreator.Stub(x => x.CreateDnaDataReader("commentforumcreate")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("createnewuserforforum")).Return(reader);
            
            reader.Stub(x => x.Read()).Return(true);
            reader.Stub(x => x.GetInt32NullAsZero("forumid")).Return(forumId);

            mocks.ReplayAll();

            var context = new Context(null, readerCreator, cacheManager, siteList);

            context.CreateForum(commentForum, site);

            readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentforumcreate"));
            readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("createnewuserforforum"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:34,代码来源:ContextTest.cs

示例3: ForumCreate_DBError_ThrowsError

        public void ForumCreate_DBError_ThrowsError()
        {
            var commentForum = new Forum
            {
                Id = "".PadRight(10, 'a'),
                ParentUri = "http://www.bbc.co.uk/dna",
                Title = "title",
                ModerationServiceGroup = ModerationStatus.ForumStatus.PostMod,
                CloseDate = DateTime.Now.AddDays(2)
            };
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var site = mocks.DynamicMock<ISite>();
            var cacheManager = mocks.DynamicMock<ICacheManager>();
            var reader = mocks.DynamicMock<IDnaDataReader>();
            readerCreator.Stub(x => x.CreateDnaDataReader("commentforumcreate")).Return(reader);
            reader.Stub(x => x.Execute()).Throw(new Exception("DB ERROR"));


            mocks.ReplayAll();

            var context = new Context(null, readerCreator, cacheManager, null);


            try
            {
                context.CreateForum(commentForum, site);
                throw new Exception("Error not thrown within code");
            }
            catch (ApiException ex)
            {
                Assert.AreEqual(ErrorType.Unknown, ex.type);
            }
            readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentforumcreate"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:34,代码来源:ContextTest.cs

示例4: ForumCreate_WithDuration_ReturnsOK

        public void ForumCreate_WithDuration_ReturnsOK()
        {
            var commentForum = new Forum
            {
                Id = "".PadRight(10, 'a'),
                ParentUri = "http://www.bbc.co.uk/dna",
                Title = "title",
                ModerationServiceGroup = ModerationStatus.ForumStatus.PostMod,
                CloseDate = DateTime.Now.AddDays(2)
            };
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var reader = mocks.DynamicMock<IDnaDataReader>();
            var site = mocks.DynamicMock<ISite>();
            var cacheManager = mocks.DynamicMock<ICacheManager>();
            readerCreator.Stub(x => x.CreateDnaDataReader("commentforumcreate")).Return(reader);


            mocks.ReplayAll();

            var context = new Context(null, readerCreator, cacheManager, null);

            context.CreateForum(commentForum, site);

            readerCreator.AssertWasCalled(x => x.CreateDnaDataReader("commentforumcreate"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:25,代码来源:ContextTest.cs

示例5: ForumCreate_WithoutSite_ThrowsError

        public void ForumCreate_WithoutSite_ThrowsError()
        {
            var commentForum = new Forum
            {
                Id = "".PadRight(10, 'a'),
                ParentUri = "http://www.bbc.co.uk/dna",
                Title = "title"
            };
            var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            var site = mocks.DynamicMock<ISite>();
            var cacheManager = mocks.DynamicMock<ICacheManager>();
            //readerCreator.Stub(x => x.CreateDnaDataReader("getmoderationclasslist")).Return(reader);


            mocks.ReplayAll();

            var context = new Context(null, readerCreator, cacheManager, null);


            try
            {
                context.CreateForum(commentForum, null);
                throw new Exception("Error not thrown within code");
            }
            catch (ApiException ex)
            {
                Assert.AreEqual(ErrorType.UnknownSite, ex.type);
            }
            readerCreator.AssertWasNotCalled(x => x.CreateDnaDataReader("commentforumcreate"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:30,代码来源:ContextTest.cs


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