public void GivenRequestToContactFormListPageShouldSetSkipAndShowVariablesInXML() { Mockery mock = new Mockery(); IInputContext mockedInputContext = mock.NewMock<IInputContext>(); ISite mockedSite = mock.NewMock<ISite>(); Stub.On(mockedSite).GetProperty("SiteID").Will(Return.Value(1)); Stub.On(mockedInputContext).GetProperty("CurrentSite").Will(Return.Value(mockedSite)); IDnaDataReader mockedReader = mock.NewMock<IDnaDataReader>(); Stub.On(mockedReader).Method("AddParameter"); Stub.On(mockedReader).Method("Execute"); Stub.On(mockedReader).GetProperty("HasRows").Will(Return.Value(false)); Stub.On(mockedReader).Method("Dispose"); Stub.On(mockedInputContext).Method("CreateDnaDataReader").With("getcontactformslist").Will(Return.Value(mockedReader)); ContactFormListBuilder contactFormBuilder = new ContactFormListBuilder(mockedInputContext); int expectedShow = 200; int expectedSkip = 1000; int expectedSiteID = 66; Stub.On(mockedInputContext).Method("DoesParamExist").With("action", "process action param").Will(Return.Value(false)); Stub.On(mockedInputContext).Method("DoesParamExist").With("dnaskip", "Items to skip").Will(Return.Value(true)); Stub.On(mockedInputContext).Method("DoesParamExist").With("dnashow", "Items to show").Will(Return.Value(true)); Stub.On(mockedInputContext).Method("GetParamIntOrZero").With("dnaskip", "Items to skip").Will(Return.Value(expectedSkip)); Stub.On(mockedInputContext).Method("GetParamIntOrZero").With("dnashow", "Items to show").Will(Return.Value(expectedShow)); Stub.On(mockedInputContext).Method("GetParamIntOrZero").With("dnasiteid", "The specified site").Will(Return.Value(expectedSiteID)); XmlNode requestResponce = contactFormBuilder.GetContactFormsAsXml(); Assert.AreEqual(expectedShow, Int32.Parse(requestResponce.SelectSingleNode("@SHOW").Value)); Assert.AreEqual(expectedSkip, Int32.Parse(requestResponce.SelectSingleNode("@SKIP").Value)); Assert.AreEqual(expectedSiteID, Int32.Parse(requestResponce.SelectSingleNode("@REQUESTEDSITEID").Value)); }
/// <summary> /// Method called to try and get the comment forum list. /// </summary> public void TryGetCommentForumList() { int siteID = 0; string hostpageurl = String.Empty; int show = InputContext.GetSiteOptionValueInt("CommentForum", "DefaultShow"); int skip = 0; int dnaUidCount = 0; string[] dnaUids; string dnaListNs = String.Empty; int dnaListCount = 0; GetPageParams(ref siteID, ref hostpageurl, ref skip, ref show, ref dnaUidCount, out dnaUids, ref dnaListNs, ref dnaListCount); BaseResult result = ProcessCommand(siteID, skip, show); if (result != null) { SerialiseAndAppend(result, ""); } if (_displayContactForms) { // Hand over all work to the Contact forms builder ContactFormListBuilder contactForms = new ContactFormListBuilder(InputContext); ImportAndAppend(contactForms.GetContactFormsAsXml(),""); } else if (hostpageurl == String.Empty || _skipUrlProcessing == true) { if (dnaUidCount != 0 && _skipUidProcessing != true) { GeneratePageXmlByDnaUids(dnaUids); } else if (dnaListNs.CompareTo("") != 0) { GeneratePageXmlByPrefix(dnaListNs, dnaListCount, siteID); } else if (siteID == 0) { GeneratePageXmlAll(skip, show); } else { GeneratePageXmlBySite(siteID, skip, show); } } else if (hostpageurl.Length > 0) { GeneratePageXmlByUrl(hostpageurl, skip, show); } }