コード例 #1
0
        public void FilterTestStartingList()
        {
            var expectedResult = new List <string> {
                "file1"
            };
            var mockedDatabase = new Mock <IProgramDatabase>();
            var firstOperator  = new And("test");

            mockedDatabase = GeneralFunctions.SetupDatabaseTryGetTokenDocumentIDs(
                mockedDatabase,
                firstOperator.Token,
                new List <string> {
                "file1", "file3"
            },
                true
                );
            var secondOperator = new And("test2");

            mockedDatabase = GeneralFunctions.SetupDatabaseTryGetTokenDocumentIDs(
                mockedDatabase,
                secondOperator.Token,
                new List <string> {
                "file1", "file2"
            },
                true
                );
            var testResult = new List <string> {
                "file1", "file2", "file3"
            };

            testResult = firstOperator.Filter(testResult, mockedDatabase.Object);
            testResult = secondOperator.Filter(testResult, mockedDatabase.Object);
            Assert.Equal(expectedResult, testResult);
        }
コード例 #2
0
        public void FilterTestWithEmptyStartingList()
        {
            var       expectedResult = new List <string>();
            var       invertedIndex  = GeneralFunctions.InitialInvertedIndex();
            IOperator firestOperator = new And("test", invertedIndex);
            var       testResult     = new List <string>();

            testResult = firestOperator.Filter(testResult);
            Assert.Equal(expectedResult, testResult);
        }
コード例 #3
0
        public void FilterTestInvalidToken()
        {
            var       expectedResult = new List <string>();
            var       invertedIndex  = GeneralFunctions.InitialInvertedIndex();
            IOperator firestOperator = new And("invalid", invertedIndex);
            var       testResult     = new List <string> {
                "file1", "file2", "file3"
            };

            testResult = firestOperator.Filter(testResult);
            Assert.Equal(expectedResult, testResult);
        }
コード例 #4
0
        public void FilterTestStartingList()
        {
            var expectedResult = new List <string> {
                "file1"
            };
            var       invertedIndex  = GeneralFunctions.InitialInvertedIndex();
            IOperator firestOperator = new And("test", invertedIndex);
            IOperator secondOperator = new And("test2", invertedIndex);
            var       testResult     = new List <string> {
                "file1", "file2", "file3"
            };

            testResult = firestOperator.Filter(testResult);
            testResult = secondOperator.Filter(testResult);
            Assert.Equal(expectedResult, testResult);
        }
コード例 #5
0
        public void FilterTestInvalidToken()
        {
            var expectedResult = new List <string>();
            var mockedDatabase = new Mock <IProgramDatabase>();
            var testOperator   = new And("invalid");

            mockedDatabase = GeneralFunctions.SetupDatabaseTryGetTokenDocumentIDs(
                mockedDatabase,
                testOperator.Token,
                new List <string>(),
                false
                );
            var testResult = new List <string> {
                "file1", "file2", "file3"
            };

            testResult = testOperator.Filter(testResult, mockedDatabase.Object);
            Assert.Equal(expectedResult, testResult);
        }
コード例 #6
0
        public void FilterTestwithNullStartingList()
        {
            var expectedResult = new List <string>();
            var mockedDatabase = new Mock <IProgramDatabase>();
            var testOperator   = new And("test");

            mockedDatabase = GeneralFunctions.SetupDatabaseTryGetTokenDocumentIDs(
                mockedDatabase,
                testOperator.Token,
                new List <string> {
                "file1"
            },
                true
                );
            List <string> testResult = null;

            testResult = testOperator.Filter(testResult, mockedDatabase.Object);
            Assert.Equal(expectedResult, testResult);
        }