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


C# Contacts.CreateContactForm方法代码示例

本文整理汇总了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();
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:64,代码来源:ContactTests.cs

示例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;
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:29,代码来源:ContactTests.cs

示例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;
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:25,代码来源:ContactTests.cs

示例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;
            }
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:20,代码来源:ContactTests.cs

示例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;
     }
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:13,代码来源:ContactTests.cs


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