本文整理汇总了C#中Contacts.CreateContactForm方法的典型用法代码示例。如果您正苦于以下问题:C# Contacts.CreateContactForm方法的具体用法?C# Contacts.CreateContactForm怎么用?C# Contacts.CreateContactForm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contacts
的用法示例。
在下文中一共展示了Contacts.CreateContactForm方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldCreateNewContactFormWhenGivenValidContactFormDetails
public void ShouldCreateNewContactFormWhenGivenValidContactFormDetails()
{
string expectedTitle = "testcontactform";
string expectedParentUri = "http://local.bbc.co.uk/dna/h2g2";
string expectedId = "newcontactform" + DateTime.Now.Ticks.ToString();
string expectedContactEmail = "[email protected]";
string expectedSiteName = "h2g2";
ModerationStatus.ForumStatus expectedModerationStatus = ModerationStatus.ForumStatus.Reactive;
ISite mockedSite = mocks.StrictMock<ISite>();
mockedSite.Stub(x => x.EditorsEmail).Return("[email protected]");
mockedSite.Stub(x => x.SiteName).Return(expectedSiteName);
ISiteList mockedSiteList = mocks.DynamicMock<ISiteList>();
mockedSiteList.Stub(x => x.GetSite(expectedSiteName)).Return(mockedSite);
ContactForm newContactFormDetails = new ContactForm();
newContactFormDetails.ContactEmail = expectedContactEmail;
newContactFormDetails.Title = expectedTitle;
newContactFormDetails.ParentUri = expectedParentUri;
newContactFormDetails.Id = expectedId;
newContactFormDetails.ModerationServiceGroup = expectedModerationStatus;
newContactFormDetails.SiteName = expectedSiteName;
newContactFormDetails.NotSignedInUserId = 0;
IDnaDataReader mockedDataReader1 = MockedGetContactFormDetailFromFormID(newContactFormDetails, false);
int expectedForumId = 789654123;
IDnaDataReader mockedDataReader2 = MockedCreateCommentForum(newContactFormDetails, expectedForumId);
newContactFormDetails.ForumID = expectedForumId;
IDnaDataReader mockedDataReader3 = MockedSetCommentForumAsContactForm(newContactFormDetails);
IDnaDataReader mockedDataReader4 = MockedGetContactFormDetailFromFormID(newContactFormDetails, true);
Queue<IDnaDataReader> mockedReaders = new Queue<IDnaDataReader>();
mockedReaders.Enqueue(mockedDataReader1);
mockedReaders.Enqueue(mockedDataReader4);
IDnaDataReaderCreator mockerDataReaderCreator = mocks.StrictMock<IDnaDataReaderCreator>();
mockerDataReaderCreator.Expect(x => x.CreateDnaDataReader("getcontactformdetailfromformid")).Return(mockedDataReader1);
mockerDataReaderCreator.Expect(x => x.CreateDnaDataReader("getcontactformdetailfromformid")).Return(mockedDataReader4);
mockerDataReaderCreator.Stub(x => x.CreateDnaDataReader("commentforumcreate")).Return(mockedDataReader2);
mockerDataReaderCreator.Stub(x => x.CreateDnaDataReader("setcommentforumascontactform")).Return(mockedDataReader3);
ICallingUser mockedUser = mocks.StrictMock<ICallingUser>();
mockedUser.Stub(x => x.IsUserA(UserTypes.Editor)).Return(true);
Contacts contacts = new Contacts(null, mockerDataReaderCreator, null, mockedSiteList);
contacts.CallingUser = mockedUser;
mocks.ReplayAll();
ContactForm createdContactForm = contacts.CreateContactForm(newContactFormDetails, mockedSiteList.GetSite("h2g2"));
Assert.AreEqual(expectedContactEmail, createdContactForm.ContactEmail);
Assert.AreEqual(expectedForumId, createdContactForm.ForumID);
Assert.AreEqual(expectedId, createdContactForm.Id);
Assert.AreEqual(expectedParentUri, createdContactForm.ParentUri);
Assert.AreEqual(expectedTitle, createdContactForm.Title);
Assert.AreEqual(expectedSiteName, createdContactForm.SiteName);
mocks.VerifyAll();
}
示例2: ShouldThrowInvalidContactEmailExceptionWhenCreatingANewFormGivenAnInvalidContactEmailAddress
public void ShouldThrowInvalidContactEmailExceptionWhenCreatingANewFormGivenAnInvalidContactEmailAddress()
{
string sitename = "h2g2";
ISite mockedSite = mocks.StrictMock<ISite>();
mockedSite.Stub(x => x.SiteName).Return(sitename);
ContactForm form = new ContactForm() { Id = "doesnotexist", SiteName = sitename, ContactEmail = "[email protected]" };
IDnaDataReader mockedDataReader = MockedGetContactFormDetailFromFormID(form, false);
IDnaDataReaderCreator mockerDataReaderCreator = mocks.StrictMock<IDnaDataReaderCreator>();
mockerDataReaderCreator.Expect(x => x.CreateDnaDataReader("getcontactformdetailfromformid")).Return(mockedDataReader);
Contacts contacts = new Contacts(null, mockerDataReaderCreator, null, null);
ICallingUser mockedUser = mocks.StrictMock<ICallingUser>();
mockedUser.Stub(x => x.IsUserA(UserTypes.Editor)).Return(true);
contacts.CallingUser = mockedUser;
mocks.ReplayAll();
try
{
ContactForm createdContactForm = contacts.CreateContactForm(form, mockedSite);
}
catch (ApiException ex)
{
Assert.AreEqual(ApiException.GetError(ErrorType.InvalidContactEmail).Message, ex.Message);
throw ex;
}
}
示例3: ShouldThrowNotAuthorizedExceptionWhenCreatingANullCallingUser
public void ShouldThrowNotAuthorizedExceptionWhenCreatingANullCallingUser()
{
string sitename = "h2g2";
ISite mockedSite = mocks.StrictMock<ISite>();
mockedSite.Stub(x => x.SiteName).Return(sitename);
ContactForm form = new ContactForm() { Id = "doesnotexist", SiteName = sitename };
IDnaDataReader mockedDataReader = MockedGetContactFormDetailFromFormID(form, false);
IDnaDataReaderCreator mockerDataReaderCreator = mocks.StrictMock<IDnaDataReaderCreator>();
mockerDataReaderCreator.Expect(x => x.CreateDnaDataReader("getcontactformdetailfromformid")).Return(mockedDataReader);
Contacts contacts = new Contacts(null, mockerDataReaderCreator, null, null);
mocks.ReplayAll();
try
{
ContactForm createdContactForm = contacts.CreateContactForm(form, mockedSite);
}
catch (ApiException ex)
{
Assert.AreEqual(ApiException.GetError(ErrorType.NotAuthorized).Message, ex.Message);
throw ex;
}
}
示例4: ShouldThrowInvalidContactEmailExceptionWhenCreatingANewFormGivenNoContactFormDetails
public void ShouldThrowInvalidContactEmailExceptionWhenCreatingANewFormGivenNoContactFormDetails()
{
string sitename = "h2g2";
ISite mockedSite = mocks.StrictMock<ISite>();
mockedSite.Stub(x => x.SiteName).Return(sitename);
Contacts contacts = new Contacts(null, null, null, null);
mocks.ReplayAll();
try
{
ContactForm createdContactForm = contacts.CreateContactForm(null, mockedSite);
}
catch (ApiException ex)
{
Assert.AreEqual(ApiException.GetError(ErrorType.InvalidContactEmail).Message, ex.Message);
throw ex;
}
}
示例5: ShouldThrowUnknownSiteExceptionWhenCreatingANewFormGivenANullSite
public void ShouldThrowUnknownSiteExceptionWhenCreatingANewFormGivenANullSite()
{
Contacts contacts = new Contacts(null, null, null, null);
try
{
ContactForm createdContactForm = contacts.CreateContactForm(null, null);
}
catch (ApiException ex)
{
Assert.AreEqual(ApiException.GetError(ErrorType.UnknownSite).Message, ex.Message);
throw ex;
}
}