本文整理汇总了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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}