예제 #1
0
        static public ArticleInfoPageAuthor CreateListForArticle(int h2g2Id, int editorId, IDnaDataReaderCreator readerCreator)
        {

            ArticleInfoPageAuthor author = new ArticleInfoPageAuthor();
            
            // Create the datareader to get the authors
            using (IDnaDataReader reader = readerCreator.CreateDnaDataReader("getauthorsfromh2g2id"))
            {
                reader.AddParameter("h2g2ID", h2g2Id);
                reader.Execute();

                // Now go through all the results in turn
                int lastUserID = 0;
                while (reader.Read())
                {
                    // Get the current researcher
                    int researcherID = reader.GetInt32("UserID");
                    if (researcherID != lastUserID)
                    {
                        // Check to see if we've just got the editors results
                        User researcher = User.CreateUserFromReader(reader);
                        author.Researchers.Add(researcher);
                        if (researcherID == editorId)
                        {
                            author.Editor = new UserElement() { user = researcher };
                        }
                        lastUserID = researcherID;
                    }
                }
            }
            return author;
        }
예제 #2
0
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        

        public static ArticleInfoPageAuthor CreatePageAuthor()
        {
            ArticleInfoPageAuthor target = new ArticleInfoPageAuthor();
            target.Editor = new UserElement() { user = UserTest.CreateTestUser() };
            target.Researchers.Add(UserTest.CreateTestUser());
            target.Researchers.Add(UserTest.CreateTestUser());
            target.Researchers.Add(UserTest.CreateTestUser());
            return target;
        }