public void Test03CorrectReturn() { Console.WriteLine("Before Test03CorrectReturn"); DnaTestURLRequest dnaRequest = new DnaTestURLRequest("h2g2"); dnaRequest.SetCurrentUserEditor(); //create a dummy articles IInputContext context = DnaMockery.CreateDatabaseInputContext(); ISite siteContext = DnaMockery.CreateMockedSite(context, 1, "", "h2g2", true, "http://identity/policies/dna/adult"); TestDataCreator testData = new TestDataCreator(context); int[] entryIDs = new int[1]; int[] h2g2IDs = new int[1]; Assert.IsTrue(testData.CreateEntries(siteContext.SiteID, dnaRequest.CurrentUserID, 3001, 3, ref entryIDs, ref h2g2IDs), "Articles not created"); int[] recommendationIds = new int[1]; Assert.IsTrue(testData.CreateRecommendations(dnaRequest.CurrentUserID, entryIDs, ref recommendationIds), "Recommendation not created"); Assert.IsTrue(testData.AcceptRecommendations(dnaRequest.CurrentUserID, recommendationIds), "Recommendation accepted"); dnaRequest = new DnaTestURLRequest("h2g2"); dnaRequest.SetCurrentUserEditor(); dnaRequest.UseEditorAuthentication = true; string relativePath = @"SubbedArticleStatus" + h2g2IDs[0] + "?skin=purexml"; dnaRequest.RequestPage(relativePath); XmlDocument xmlResponse = dnaRequest.GetLastResponseAsXML(); //check for error tag XmlNode xmlError = xmlResponse.SelectSingleNode("/H2G2/ERROR"); Assert.IsTrue(xmlError == null, "Incorrect error returned"); XmlNode xmlSub = xmlResponse.SelectSingleNode("/H2G2/SUBBED-ARTICLES"); Assert.IsTrue(xmlSub != null, "Incorrect data returned"); Console.WriteLine("After Test02MissingSubbedArticle"); }
public void Test03_CorrectAllocationTests() { DnaTestURLRequest dnaRequest = new DnaTestURLRequest("h2g2"); dnaRequest.SetCurrentUserEditor(); //create a dummy articles IInputContext context = DnaMockery.CreateDatabaseInputContext(); ISite siteContext = DnaMockery.CreateMockedSite(context, 1, "", "h2g2", true, "comment"); TestDataCreator testData = new TestDataCreator(context); entryIDs = new int[10]; h2g2IDs = new int[10]; Assert.IsTrue(testData.CreateEntries(siteContext.SiteID, dnaRequest.CurrentUserID, 3001, 3, ref entryIDs, ref h2g2IDs), "Articles not created"); recommendationIds = new int[10]; Assert.IsTrue(testData.CreateRecommendations(dnaRequest.CurrentUserID, entryIDs, ref recommendationIds), "Recommendation not created"); Assert.IsTrue(testData.AcceptRecommendations(dnaRequest.CurrentUserID, recommendationIds), "Recommendation accepted"); //create test sub editors userIDs = new int[10]; Assert.IsTrue(testData.CreateNewUsers(siteContext.SiteID, ref userIDs), "Test users not created"); Assert.IsTrue(testData.CreateNewUserGroup(dnaRequest.CurrentUserID, "subs"), "CreateNewUserGroup not created"); Assert.IsTrue(testData.AddUsersToGroup(userIDs, siteContext.SiteID, "subs"), "Unable to add users to group not created"); //get unallocated values from list dnaRequest = new DnaTestURLRequest("h2g2"); dnaRequest.SetCurrentUserEditor(); dnaRequest.UseEditorAuthentication = true; string relativePath = "allocatesubs?skin=purexml"; dnaRequest.RequestPage(relativePath); XmlDocument xmlResponse = dnaRequest.GetLastResponseAsXML(); Assert.IsTrue(xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM") != null, "Incorrect data returned"); Assert.IsTrue(xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM/UNALLOCATED-RECOMMENDATIONS") != null, "Incorrect data returned"); //update entryids with unallocated values XmlNode unallocRecommendations = xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM/UNALLOCATED-RECOMMENDATIONS/ARTICLE-LIST"); for (int i = 0; i < entryIDs.Length && i < unallocRecommendations.ChildNodes.Count; i++) { entryIDs[i] = Int32.Parse(unallocRecommendations.ChildNodes[i].SelectSingleNode("ENTRY-ID").InnerText); } //allocate 2 articles to sub editor dnaRequest = new DnaTestURLRequest("h2g2"); dnaRequest.SetCurrentUserEditor(); dnaRequest.UseEditorAuthentication = true; relativePath = "allocatesubs?&Command=ALLOCATE&EntryID=" + entryIDs[0] + "&EntryID=" + entryIDs[1] + "&SubID=" + userIDs[0] + "&skin=purexml"; dnaRequest.RequestPage(relativePath); xmlResponse = dnaRequest.GetLastResponseAsXML(); Assert.IsTrue(xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM") != null, "Incorrect data returned"); Assert.IsTrue(xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM/SUCCESSFUL-ALLOCATIONS") != null, "Incorrect data returned"); Assert.IsTrue(xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM/FAILED-ALLOCATIONS") != null, "Incorrect data returned"); //deallocate those two relativePath = @"AllocateSubs?command=DEALLOCATE&DeallocateID=" + entryIDs[0] + "&DeallocateID=" + entryIDs[1] + "&SubID=" + userIDs[0] + "&skin=purexml"; dnaRequest.RequestPage(relativePath); xmlResponse = dnaRequest.GetLastResponseAsXML(); Assert.IsTrue(xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM") != null, "Incorrect data returned"); Assert.IsTrue(xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM/SUCCESSFUL-DEALLOCATIONS") != null, "Incorrect data returned"); Assert.IsTrue(xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM/FAILED-DEALLOCATIONS") != null, "Incorrect data returned"); //auto allocate some relativePath = @"AllocateSubs?command=AUTOALLOCATE&Amount=2&SubID=" + userIDs[0] + "&skin=purexml"; dnaRequest.RequestPage(relativePath); xmlResponse = dnaRequest.GetLastResponseAsXML(); Assert.IsTrue(xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM") != null, "Incorrect data returned"); Assert.IsTrue(xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM/SUCCESSFUL-ALLOCATIONS") != null, "Incorrect data returned"); Assert.IsTrue(xmlResponse.SelectSingleNode("/H2G2/SUB-ALLOCATION-FORM/FAILED-ALLOCATIONS") != null, "Incorrect data returned"); }
private void SetupRecommendations() { //create a dummy articles IInputContext context = DnaMockery.CreateDatabaseInputContext(); ISite siteContext = DnaMockery.CreateMockedSite(context, 1, "", "h2g2", true, "http://identity/policies/dna/adult"); TestDataCreator testData = new TestDataCreator(context); int[] entryIDs = new int[1]; int[] h2g2IDs = new int[1]; Assert.IsTrue(testData.CreateEntries(siteContext.SiteID, _request.CurrentUserID, 3001, 3, ref entryIDs, ref h2g2IDs), "Articles not created"); Assert.IsTrue(testData.CreateRecommendations(_request.CurrentUserID, entryIDs, ref _recommendationIds), "Recommendation not created"); }