예제 #1
0
        /// <summary>
        /// Used to process the current request.
        /// </summary>
        public override void ProcessRequest()
        {
            //if not an editor or scout then return an error
            if (InputContext.ViewingUser.UserID == 0 || !(InputContext.ViewingUser.IsEditor || InputContext.ViewingUser.IsScout))
            {
                AddErrorXml("NOT-EDITOR", "You cannot allocate recommended entries to sub editors unless you are logged in as an Editor.", RootElement);
                return;
            }

            ArticleList recommendations = new ArticleList(InputContext);
            recommendations.CreateUndecidedRecommendationsList(0, 50);

            RootElement.RemoveAll();
            XmlElement undecidedRecommendations = AddElementTag(RootElement, "UNDECIDED-RECOMMENDATIONS");
            AddInside(undecidedRecommendations, recommendations);  
        }
예제 #2
0
        public void TestGetUndecidedRecommendationsArticleListTest()
        {
            Console.WriteLine("Before ArticleListTests - TestGetUndecidedRecommendationsArticleListTest");
            //Create the mocked inputcontext
            Mockery mock = new Mockery();

            // Create the app context for the poll to run in
            string rootPath = TestConfig.GetConfig().GetRipleyServerPath();
            BBC.Dna.AppContext.OnDnaStartup(rootPath);

            // Create the stored procedure reader for the CommentList object
            IInputContext context = DnaMockery.CreateDatabaseInputContext();

            //XmlDocument siteconfig = new XmlDocument();
            //siteconfig.LoadXml("<SITECONFIG />");

            ISite site = mock.NewMock<ISite>();
            //Stub.On(site).GetProperty("SiteConfig").Will(Return.Value(siteconfig.FirstChild));
            Stub.On(site).GetProperty("SiteID").Will(Return.Value(1));

            User user = new User(context);
            Stub.On(context).GetProperty("ViewingUser").Will(Return.Value(user));
            Stub.On(context).GetProperty("CurrentSite").Will(Return.Value(site));

            SetupArticles(context);

            using (IDnaDataReader reader = context.CreateDnaDataReader("FetchUndecidedRecommendations"))
            {
                Stub.On(context).Method("CreateDnaDataReader").With("FetchUndecidedRecommendations").Will(Return.Value(reader));

                // Create a new ArtiocleList object and get the list of undecided articles
                ArticleList testArticleList = new ArticleList(context);
                testArticleList.CreateUndecidedRecommendationsList(0, 50);

                XmlElement xml = testArticleList.RootElement;
                Assert.IsTrue(xml.SelectSingleNode("ARTICLE-LIST") != null, "The xml is not generated correctly!!!");

                Assert.IsTrue(xml.SelectSingleNode("ARTICLE-LIST[@TYPE='UNDECIDED-RECOMMENDATIONS']") != null, "The xml is not generated correctly (TYPE != UNDECIDED-RECOMMENDATIONS)!!!");

                DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
                validator.Validate();

            }
            Console.WriteLine("After ArticleListTests - TestGetUndecidedRecommendationsArticleListTest");
        }