Ejemplo n.º 1
0
        public void AddDuplicateKeyword()
        {
            String expectedkeyword = "Testing";
            Paper existingpaper = new Paper();

            existingpaper.addKeyword(expectedkeyword);
            existingpaper.addKeyword(expectedkeyword);
        }
Ejemplo n.º 2
0
        public void AddNumericalKeyword()
        {
            String expectedkeyword = "1234";
            Paper existingpaper = new Paper();

            existingpaper.addKeyword(expectedkeyword);
        }
Ejemplo n.º 3
0
        public void AddNullStringKeyword()
        {
            String expectedkeyword = null;
            Paper existingpaper = new Paper();

            existingpaper.addKeyword(expectedkeyword);
        }
Ejemplo n.º 4
0
        public void AddEmptyStringKeyword()
        {
            String expectedkeyword = "";
            Paper existingpaper = new Paper();

            existingpaper.addKeyword(expectedkeyword);
        }
Ejemplo n.º 5
0
        public void AddNormalUniqueKeyword()
        {
            String expectedkeyword = "Testing";
            Paper existingpaper = new Paper();
            Author a = new Author();

            existingpaper.addKeyword(expectedkeyword);
            List<String> keywords = existingpaper.listKeywords();
            List<String> authorkeywords = a.listKeywords();

            String actual = keywords.Find(s => s == expectedkeyword);
            Assert.AreEqual(actual, expectedkeyword);

            actual = authorkeywords.Find(s => s == expectedkeyword);
            Assert.AreEqual(actual, expectedkeyword);
        }
Ejemplo n.º 6
0
        public void SearchNormal_NonExistingKeyword()
        {
            //  create paper with keyword of "Doppler Effect"
            String existingKeyword = "Doppler Effect";
            Paper existingPaper = new Paper();
            existingPaper.addKeyword(existingKeyword);

            //  add paper to a database
            Database allPapers = new Database();
            Database.addPaper(allPapers, existingPaper);

            //  search database using non-existing keyword of "Fusion"
            String nonExistingKeyword = "Fusion";
            List<Paper> searchedPaper = Database.searchByKeyword(allPapers, nonExistingKeyword);

            //  check if search result returns null (found no matches for "Fusion")
            Assert.AreEqual(searchedPaper, null);
        }
Ejemplo n.º 7
0
        public void SearchNormal_ExistingKeyword_SinglePaper()
        {
            //  create paper with keyword of "Doppler Effect"
            String existingKeyword = "Doppler Effect";
            Paper existingPaper = new Paper();
            existingPaper.addKeyword(existingKeyword);

            //  add paper to a database
            Database allPapers = new Database();
            Database.addPaper(allPapers, existingPaper);

            //  search database using keyword of "Doppler Effect"
            List<Paper> searchedPaper = Database.searchByKeyword(allPapers, existingKeyword);

            //  check if search result returns null (found no matches for "Doppler Effect")
            if (searchedPaper == null) Assert.Fail();

            //  check if search result matches the added paper
            Assert.AreEqual(existingPaper, searchedPaper[0]);
        }
Ejemplo n.º 8
0
        public void SearchProblem_NullKeywordGiven()
        {
            //  create paper with keyword of "Doppler Effect"
            String existingKeyword = "Doppler Effect";
            Paper existingPaper = new Paper();
            existingPaper.addKeyword(existingKeyword);

            //  add paper to a database
            Database allPapers = new Database();
            Database.addPaper(allPapers, existingPaper);

            //  search database using null keyword
            List<Paper> searchedPaper = Database.searchByKeyword(allPapers, null);

            //  check if search result returns null (found no matches for null keyword)
            Assert.AreEqual(searchedPaper, null);
        }