示例#1
0
文件: Author.cs 项目: rajjj/SENGP4
 /**This method returns the number of publication that the author has written
  * Note: his SystematicMappingSystem class has a method that returns the list
  * of the authorspublications
  * **/
 public int numberOfPublications(SystematicMappingSystem sms, Author chosenAuthor)
 {
     int numPublications = 0;
     Paper[] publication = sms.searchAuthorPublications(chosenAuthor).ToArray();
     foreach (Paper p in publication)
     {
         numPublications++;
     }
     return numPublications;
 }
示例#2
0
 public void AuthorPublication_invalidAuthorName_integer()
 {
     string invalidName = "123";
     Paper publication = new Paper("P1");
     Author chosenAuthor = new Author(invalidName);
     SystematicMappingSystem sms = new SystematicMappingSystem();
     sms.AddPaper(publication);
     int expected = chosenAuthor.numberOfPublications(sms, chosenAuthor);
     int actual = 0;
     Assert.AreEqual(expected, actual);
 }
示例#3
0
 public void AuthorPublication_invalidAuthorName_controlCharacters()
 {
     Paper publication = new Paper("P1");
     string invalidName = "./(())())()()";
     Author chosenAuthor = new Author(invalidName);
     SystematicMappingSystem sms = new SystematicMappingSystem();
     sms.AddPaper(publication);
     int expected = chosenAuthor.numberOfPublications(sms, chosenAuthor);
     int actual = 0;
     Assert.AreEqual(expected, actual);
 }
示例#4
0
 public void AuthorPublication_authorDoesNotExist()
 {
     Paper publication = new Paper("P1");
     string fakeAuthor = "Joe";
     Author chosenAuthor = new Author(fakeAuthor);
     SystematicMappingSystem sms = new SystematicMappingSystem();
     sms.AddPaper(publication);
     int expected = chosenAuthor.numberOfPublications(sms, chosenAuthor);
     int actual = 0;
     Assert.AreEqual(expected, actual);
 }
示例#5
0
        public void TestMethod3()
        {
            //Create Keyword and Paper
            Keyword expectedKeyword = new Keyword(null);
            Paper expectedPaper = new Paper("Some Paper About Testing");

            //Add keyword to paper
            expectedPaper.AddKeyword(expectedKeyword);

            //A mapping system to store the papers in
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add paper to the system
            sms.AddPaper(expectedPaper);

            List<Keyword> keyWordsList = sms.GetKeywordsFromPaper("Some Paper About Testing");
            Assert.Fail();
        }
示例#6
0
        public void TestMethod1()
        {
            //Create Keyword and Paper
            Keyword expectedKeyword = new Keyword("Testing");
            Paper expectedPaper = new Paper("Some Paper About Testing");

            //Add keyword to paper
            expectedPaper.AddKeyword(expectedKeyword);

            //A mapping system to store the papers in
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add paper to the system
            sms.AddPaper(expectedPaper);

            List<Keyword> keyWordsList = sms.GetKeywordsFromPaper("Some Paper About Testing");
            Assert.IsTrue(expectedKeyword.Equals(keyWordsList.First()) && keyWordsList.Count() == 1);
        }
示例#7
0
        public void TestMethod2()
        {
            //Create Keyword and Paper
            Keyword[] expectedKeywords = { new Keyword("Testing1"), new Keyword("Testing2"), new Keyword("Testing3"), new Keyword("Testing4") };
            Paper expectedPaper = new Paper("Some Paper About Testing");

            //Add keywords to paper
            foreach (Keyword keyword in expectedKeywords)
            {
                expectedPaper.AddKeyword(keyword);
            }

            //A mapping system to store the papers in
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add paper to the system
            sms.AddPaper(expectedPaper);

            List<Keyword> keyWordsList = sms.GetKeywordsFromPaper("Some Paper About Testing");
            Assert.IsTrue(expectedKeywords[0].Equals(keyWordsList.First()) && keyWordsList.Count() == 4);
        }
示例#8
0
        public void KeywordSearchTest_EmptyString()
        {
            //The keyword is an empty string
            Keyword expectedKeyword = new Keyword("");

            //Create other keyword and add to paper
            Keyword otherKeyword = new Keyword("Other Keyword");
            Paper otherPaper = new Paper("Paper with Keywords");
            otherPaper.AddKeyword(otherKeyword);

            //Create mapping system for papers
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add otherPaper to system
            sms.AddPaper(otherPaper);

            //Search through papers with the keyword
            int expected = sms.SearchByKeyword(expectedKeyword);

            int actual = 0;
            //Assert only one paper is found
            Assert.AreEqual(expected, actual);
        }
示例#9
0
        public void KeywordSearchTest_KeywordDoesNotExist()
        {
            //Keyword that does not exist
            Keyword expectedKeyword = new Keyword("Does Not Exist");

            //Other keyword
            Keyword otherKeyword = new Keyword("Other Keyword");
            Paper otherPaper = new Paper("Paper With Other Keywords");
            //Add otherKeyword to otherPaper
            otherPaper.AddKeyword(otherKeyword);

            //Create mapping system for papers
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add otherPaper to system
            sms.AddPaper(otherPaper);

            //Search through papers with keyword - Represent in a list
            int expected = sms.SearchByKeyword(expectedKeyword);

            int actual = 0;
            //Assert only one paper is found
            Assert.AreEqual(expected, actual);
        }
示例#10
0
 public void AuthorPublication_mutiplePublications()
 {
     Paper publication1 = new Paper("P1");
     Paper publication2 = new Paper("P2");
     Paper publication3 = new Paper("P3");
     Author chosenAuthor = new Author("name2");
     //add authors to papers
     publication1.addAuthor(chosenAuthor);
     publication2.addAuthor(chosenAuthor);
     publication3.addAuthor(chosenAuthor);
     SystematicMappingSystem sms = new SystematicMappingSystem();
     //add papers to the system
     sms.AddPaper(publication1);
     sms.AddPaper(publication2);
     sms.AddPaper(publication3);
     int expected = chosenAuthor.numberOfPublications(sms, chosenAuthor);
     int actual = 3; // author has written three papers
     Assert.AreEqual(expected, actual);
 }
示例#11
0
 public void AuthorPublication_NormalPath()
 {
     Paper publication = new Paper("P1");
     Author chosenAuthor = new Author("name1");
     publication.addAuthor(chosenAuthor); // add author to paper
     SystematicMappingSystem sms = new SystematicMappingSystem();
     sms.AddPaper(publication); // add paper to the system
     int expected = chosenAuthor.numberOfPublications(sms, chosenAuthor); // get the number of papers author has wrote
     int actual = 1; // only 1 paper should exist
     Assert.AreEqual(expected, actual);
 }
示例#12
0
 public void AuthorPublication_noPublications()
 {
     Paper publication = new Paper("P1");
     string noPublicationAuthor = "name";
     Author chosenAuthor = new Author(noPublicationAuthor);
     SystematicMappingSystem sms = new SystematicMappingSystem();
     sms.AddPaper(publication);
     int expected = chosenAuthor.numberOfPublications(sms, chosenAuthor);
     int actual = 0; // should be no papers
     Assert.AreEqual(expected, actual);
 }
示例#13
0
        public void KeywordSearchTest_NormalPath()
        {
            //Create Keyword and Paper
            Keyword expectedKeyword = new Keyword("Testing");
            Paper expectedPaper = new Paper("Some Paper About Testing");
            //Add keyword to paper
            expectedPaper.AddKeyword(expectedKeyword);

            //A mapping system to store the papers in
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add paper to the system
            sms.AddPaper(expectedPaper);

            //Search by keyword for papers with keyword - Represent in a List
            int expected = sms.SearchByKeyword(expectedKeyword);

            int actual = 1;
            //Assert only one paper is found
            Assert.AreEqual(expected, actual);
        }
示例#14
0
        public void TestMethod4()
        {
            //Create Keyword and Paper
            Keyword expectedKeyword = new Keyword("abcdefghijklmnopqrstuvwxyznowiknowmyabcsnexttimewontyousingwithme");
            Paper expectedPaper = new Paper("Some Paper About Testing");

            //Add keyword to paper
            expectedPaper.AddKeyword(expectedKeyword);

            //A mapping system to store the papers in
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add paper to the system
            sms.AddPaper(expectedPaper);

            List<Keyword> keyWordsList = sms.GetKeywordsFromPaper("Some Paper About Testing");
            Assert.IsTrue(keyWordsList.Count() == 1);
        }