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


C# Context.UpdateForum方法代码示例

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


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

示例1: ForumUpdate_WithoutUid_ThrowsError

        public void ForumUpdate_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.UpdateForum(commentForum, site, null);
                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: ForumUpdate_WithDuration_ReturnsOK

        public void ForumUpdate_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("commentforumupdate")).Return(reader);


            mocks.ReplayAll();

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

            context.UpdateForum(commentForum, site, null);

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

示例3: ForumUpdate_DBError_ThrowsError

        public void ForumUpdate_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("commentforumupdate")).Return(reader);
            reader.Stub(x => x.Execute()).Throw(new Exception("DB ERROR"));


            mocks.ReplayAll();

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


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

示例4: ForumUpdate_WithoutSite_ThrowsError

        public void ForumUpdate_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.UpdateForum(commentForum, null, true);
                throw new Exception("Error not thrown within code");
            }
            catch (ApiException ex)
            {
                Assert.AreEqual(ErrorType.UnknownSite, ex.type);
            }
            readerCreator.AssertWasNotCalled(x => x.CreateDnaDataReader("commentforumupdate"));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:30,代码来源:ContextTest.cs


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