public void TopNKeywords_NBiggerThanNumberOfKeywords()
        {
            //Setup papers and keywords in database
            int year = 1999;
            Keyword someKeyword = new Keyword("top");
            Keyword someOtherKeyword = new Keyword("other");
            Paper somePaper = new Paper("Name of paper", year);
            somePaper.addKeyWord(someKeyword);
            Paper someOtherPaper = new Paper("Name of other paper", year);
            someOtherPaper.addKeyWord(someKeyword);
            someOtherPaper.addKeyWord(someOtherKeyword);
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add papers to mapping system
            sms.AddPaper(somePaper);
            sms.AddPaper(someOtherPaper);

            //now we will get the top 3 keywords from the SystematicMappingSystem stored as a list
            int N = 3;
            //this should return a list of size 2 since there are only 2 keywords for this year
            List<Keyword> keywords = sms.GetTopNKeywordsForYear(N, year);

            //Check that there are two keywords in the list
            Assert.Equals(keywords.Count, 2);
            //Check that it returned the top keywords in order
            Assert.IsTrue(keywords.ElementAt(0).Equals(someKeyword));
            Assert.IsTrue(keywords.ElementAt(1).Equals(someOtherKeyword));
        }
        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
            List<Paper> papersWithKeyword = sms.SearchByKeyword(expectedKeyword);

            //Assert only one paper is found
            Assert.IsTrue(expectedPaper.Equals(papersWithKeyword.First()) && papersWithKeyword.Count() == 1);
        }
        //Search through with Keyword
        public int SearchByKeyword(Keyword expectedKeyword)
        {
            int count = 0;
            //String to compare to
            String expected = expectedKeyword.getKeyword();

            foreach (Paper p in papers)
            {
                Keyword[] temparray = p.getKeywords();
                for (int i = 0; i < temparray.Length; i++)
                {
                    if (temparray[i].getKeyword().Equals(expected))
                    {
                        count++;
                    }

                }
            }
            return count;
        }
        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);
        }
        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
            List<Paper> papersWithKeyword = sms.SearchByKeyword(expectedKeyword);

            //Assert that no papers are found
            Assert.IsTrue(papersWithKeyword.Count() == 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
            List<Paper> papersWithKeyword = sms.SearchByKeyword(expectedKeyword);

            //Assert that no papers are founde
            Assert.IsTrue(papersWithKeyword.Count() == 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);
        }
        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);
        }
        public void TopNKeywords_InvalidYear()
        {
            //Setup papers and keywords in database
            int year = 1999;
            Keyword someKeyword = new Keyword("top");
            Keyword someOtherKeyword = new Keyword("other");
            Paper somePaper = new Paper("Name of paper", year);
            somePaper.addKeyWord(someKeyword);
            Paper someOtherPaper = new Paper("Name of other paper", year);
            someOtherPaper.addKeyWord(someKeyword);
            someOtherPaper.addKeyWord(someOtherKeyword);
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add papers to mapping system
            sms.AddPaper(somePaper);
            sms.AddPaper(someOtherPaper);

            //now we will get the top 2 keywords from the SystematicMappingSystem stored as a list for year 0, which is invalid
            int N = 2;

            List<Keyword> keywords = sms.GetTopNKeywordsForYear(N, 0);

            Assert.Fail();
        }
        public void TopNKeywords_InvalidFutureYear()
        {
            //Setup papers and keywords in database
            int year = 1999;
            Keyword someKeyword = new Keyword("top");
            Keyword someOtherKeyword = new Keyword("other");
            Paper somePaper = new Paper("Name of paper", year);
            somePaper.addKeyWord(someKeyword);
            Paper someOtherPaper = new Paper("Name of other paper", year);
            someOtherPaper.addKeyWord(someKeyword);
            someOtherPaper.addKeyWord(someOtherKeyword);
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add papers to mapping system
            sms.AddPaper(somePaper);
            sms.AddPaper(someOtherPaper);

            //now we will query for keywords to papers for a year in the future
            int N = 2;

            List<Keyword> keywords = sms.GetTopNKeywordsForYear(N, 2020);

            Assert.Fail();
        }
Example #11
0
 //Add a keyword to the paper
 public void AddKeyword(Keyword newkeyword)
 {
     k.Add(newkeyword);
 }
Example #12
0
 internal bool ContainsKeyword(Keyword expectedKeyword)
 {
     throw new NotImplementedException();
 }
Example #13
0
 internal void AddKeyword(Keyword expectedKeyword)
 {
     throw new NotImplementedException();
 }
        public void TopNKeywords_NormalPath()
        {
            //Setup papers and keywords in database
            int year = 1999;
            Keyword someKeyword = new Keyword("top");
            Keyword someOtherKeyword = new Keyword("other");
            Paper somePaper = new Paper("Name of paper", year);
            somePaper.addKeyWord(someKeyword);
            Paper someOtherPaper = new Paper("Name of other paper", year);
            someOtherPaper.addKeyWord(someKeyword);
            someOtherPaper.addKeyWord(someOtherKeyword);
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add papers to mapping system
            sms.AddPaper(somePaper);
            sms.AddPaper(someOtherPaper);

            //now we will get the top 2 keywords from the SystematicMappingSystem stored as a list
            int N = 2;

            List<Keyword> keywords = sms.GetTopNKeywordsForYear(N, year);

            //Check that there are two keywords in the list
            Assert.Equals(keywords.Count, N);
            //Check that it returned the top keywords in order
            Assert.IsTrue(keywords.ElementAt(0).Equals(someKeyword));
            Assert.IsTrue(keywords.ElementAt(1).Equals(someOtherKeyword));
        }
 internal int NumberOfPapersWithKeyword(Keyword expectedKeyword)
 {
     throw new NotImplementedException();
 }
 internal List<Paper> SearchByKeyword(Keyword expectedKeyword)
 {
     throw new NotImplementedException();
 }
        public void TopNKeywords_NoKeywordsForYear()
        {
            //Setup papers and keywords in database
            //We still add these just in case it returns these instead of nothing
            int year = 1999;
            Keyword someKeyword = new Keyword("top");
            Keyword someOtherKeyword = new Keyword("other");
            Paper somePaper = new Paper("Name of paper", year);
            somePaper.addKeyWord(someKeyword);
            Paper someOtherPaper = new Paper("Name of other paper", year);
            someOtherPaper.addKeyWord(someKeyword);
            someOtherPaper.addKeyWord(someOtherKeyword);
            SystematicMappingSystem sms = new SystematicMappingSystem();
            //Add papers to mapping system
            sms.AddPaper(somePaper);
            sms.AddPaper(someOtherPaper);

            //now we will get the top 2 keywords from the SystematicMappingSystem stored as a list for year 1998, which has no papers
            int N = 2;

            List<Keyword> keywords = sms.GetTopNKeywordsForYear(N, 1998);
            //There should be no keywords for this year;
            Assert.Equals(keywords.Count,0);
        }