public void Initialise() { using(var context = new FullInputContext("")) { var ug = new BBC.Dna.Users.UserGroups(context.ReaderCreator, context.Diagnostics, CacheFactory.GetCacheManager(), null, null); } }
public void PostHistory_GetPostHistoryAsSuperUserForAnonymousComplaint_ExpectFullComplainantDetails() { using (new TransactionScope()) { IInputContext context = DnaMockery.CreateDatabaseInputContext(); ICacheManager groupsCache = new StaticCacheManager(); var g = new BBC.Dna.Users.UserGroups(DnaMockery.CreateDatabaseReaderCreator(), null, groupsCache, null, null); int postId = 61; int userId = 0; int modId = 0; string email = "*****@*****.**"; string complaintText = "This is testing that the complainant details are correctly displayed"; string IpAddress = "192.168.238.1"; Guid BBCUid = new Guid(); ISite site = DnaMockery.CreateMockedSite(context, 1, "h2g2", "h2g2", true, "comment"); modId = RegisterTestComplaint(context, postId, userId, modId, email, complaintText, IpAddress, BBCUid); ISiteList siteList = DnaMockery.CurrentMockery.NewMock<ISiteList>(); Stub.On(siteList).Method("GetSite").With(70).Will(Return.Value(site)); Stub.On(context).Method("GetParamStringOrEmpty").With("reference", "reference").Will(Return.Value("")); Stub.On(context).Method("GetParamIntOrZero").With("postid", "postid").Will(Return.Value(postId)); Stub.On(context).Method("GetParamIntOrZero").With("h2g2id", "h2g2id").Will(Return.Value(0)); Stub.On(context).Method("GetParamStringOrEmpty").With("exlinkurl", "exlinkurl").Will(Return.Value("")); Stub.On(context).GetProperty("TheSiteList").Will(Return.Value(siteList)); IDnaDataReaderCreator creator = DnaMockery.CreateDatabaseReaderCreator(); AppContext.ReaderCreator = creator; IUser viewingUser = DnaMockery.CurrentMockery.NewMock<IUser>(); Stub.On(viewingUser).GetProperty("IsSuperUser").Will(Return.Value(true)); Stub.On(context).GetProperty("ViewingUser").Will(Return.Value(viewingUser)); ModerationHistory history = new ModerationHistory(context); history.ProcessRequest(); XmlNode modHistory = history.RootElement.SelectSingleNode("//MODERATION-HISTORY"); Assert.IsNotNull(modHistory, "Failed to find the moderation history node"); XmlNode modItem = modHistory.SelectSingleNode("MODERATION[@MODID='" + modId + "']"); Assert.IsNotNull(modItem, "Failed to find the moderation node for the complaint."); Assert.IsNotNull(modItem.SelectSingleNode("COMPLAINT/IPADDRESS"), "Failed to find complaint ipaddress"); Assert.AreEqual(IpAddress, modItem.SelectSingleNode("COMPLAINT/IPADDRESS").InnerText); Assert.IsNotNull(modItem.SelectSingleNode("COMPLAINT/COMPLAINT-TEXT"), "Failed to find complaint text"); Assert.AreEqual(complaintText, modItem.SelectSingleNode("COMPLAINT/COMPLAINT-TEXT").InnerText); Assert.IsNotNull(modItem.SelectSingleNode("COMPLAINT/BBCUID"), "Failed to find complaint BBCUID"); Assert.AreEqual(BBCUid.ToString(), modItem.SelectSingleNode("COMPLAINT/BBCUID").InnerText); Assert.IsNotNull(modItem.SelectSingleNode("COMPLAINT/EMAIL-ADDRESS"), "Failed to find complaint email address"); Assert.AreEqual(email, modItem.SelectSingleNode("COMPLAINT/EMAIL-ADDRESS").InnerText); XmlNode complainantUser = modItem.SelectSingleNode("COMPLAINT/USER"); Assert.IsNull(complainantUser, "There shouldn't be a complainant user block"); } }