public void SaveMatch_InputAndMatchAreSameButDifferentCase_NotSaved()
        {
            // Arrange
            const string inputName1 = "P1";
            const string inputName2 = "T1";
            const string inputName3 = "V1";
            const string gazName1 = "p1"; // same as input, case different
            const string gazName2 = "t1"; // same as input, case different
            const string gazName3 = "v1"; // same as input, case different

            // Arrange
            // gazetteer data - use test data 1
            GazetteerNames gazetteerNames = new GazetteerNames(
                GazetteerTestData.TestData1());

            //match provider
            var mock = MockRepository.GenerateMock<IMatchProvider>();
            MatchedNames matchedNames = new MatchedNames(mock);

            // input
            Location inputLocation = new Location(inputName1, inputName2, inputName3);

            // match from gazetteer
            Location gazetteerLocation = new Location(gazName1, gazName2, gazName3);

            // Act
            matchedNames.SaveMatch(inputLocation, gazetteerLocation, gazetteerNames);

            // Assert
            AssertNoSavesCalled(mock);
        }
        public void SaveMatch_InputAndMatchAreValid_MatchSaved()
        {
            // Arrange
            const string inputName1 = "P1x";
            const string inputName2 = "T1x";
            const string inputName3 = "V1x";
            const string gazName1 = "P1"; // main value in gaz
            const string gazName2 = "T1"; // main value in gaz
            const string gazName3 = "V1"; // main value in gaz

            // gazetteer data - use test data 1
            GazetteerNames gazetteerNames = new GazetteerNames(
                GazetteerTestData.TestData1());

            //match provider
            var mock = MockRepository.GenerateMock<IMatchProvider>();
            MatchedNames matchedNames = new MatchedNames(mock);

            // input
            Location inputLocation = new Location(inputName1, inputName2, inputName3);

            // match from gazetteer
            Location gazetteerLocation = new Location(gazName1, gazName2, gazName3);

            // Act
            matchedNames.SaveMatch(inputLocation, gazetteerLocation, gazetteerNames);

            // Assert
            mock.AssertWasCalled(x => x.SaveMatchLevel1(inputName1, gazName1));
            mock.AssertWasCalled(x => x.SaveMatchLevel2(inputName2, gazName1, gazName2));
            mock.AssertWasCalled(
                x => x.SaveMatchLevel3(inputName3, gazName1, gazName2, gazName3));
        }
        public void SaveMatch_MatchIsAltEquivalentToInput_NotSaved()
        {
            // Arrange
            const string inputName1 = "P1";
            const string inputName2 = "T1";
            const string inputName3 = "V1";
            const string gazName1 = "P1A"; // ignore as is equivalent
            const string gazName2 = "T1A"; // ignore as is equivalent
            const string gazName3 = "V1A"; // ignore as is equivalent

            // gazetteer data - use test data 1
            GazetteerNames gazetteerNames = new GazetteerNames(
                GazetteerTestData.TestData1());

            // no existing saved matches
            var mock = MockRepository.GenerateMock<IMatchProvider>();
            MatchedNames matchedNames = new MatchedNames(mock);

            // input
            Location inputLocation = new Location(inputName1, inputName2, inputName3);

            // match to gazetteer
            Location gazetteerLocation = new Location(gazName1, gazName2, gazName3);

            // Act
            matchedNames.SaveMatch(inputLocation, gazetteerLocation, gazetteerNames);

            // Assert
            AssertNoSavesCalled(mock);
        }
        public void SaveMatch_InputLevel3IsBlank_OnlyLevel1And2Saved()
        {
            // Arrange
            const string inputName1 = "P1x";
            const string inputName2 = "T1x";
            const string inputName3 = "";
            const string gazName1 = "P1";
            const string gazName2 = "T1";
            const string gazName3 = "V1";

            // Arrange
            // gazetteer data - use test data 1
            GazetteerNames gazetteerNames = new GazetteerNames(
                GazetteerTestData.TestData1());

            //match provider
            var mock = MockRepository.GenerateMock<IMatchProvider>();
            MatchedNames matchedNames = new MatchedNames(mock);

            // input
            Location inputLocation = new Location(inputName1, inputName2, inputName3);

            // match from gazetteer
            Location gazetteerLocation = new Location(gazName1, gazName2, gazName3);

            // Act
            matchedNames.SaveMatch(inputLocation, gazetteerLocation, gazetteerNames);

            // Assert
            // level 1 and 2 save called
            mock.AssertWasCalled(
                x => x.SaveMatchLevel1(inputName1, gazName1));
            mock.AssertWasCalled(
                x =>
                    x.SaveMatchLevel2(
                        inputName2,
                        gazName1,
                        gazName2));
            mock.AssertWasNotCalled(
                x =>
                    x.SaveMatchLevel3(
                        Arg<string>.Is.Anything,
                        Arg<string>.Is.Anything,
                        Arg<string>.Is.Anything,
                        Arg<string>.Is.Anything));
        }
        public void SaveMatch_InputLevel3ExistsInGazAsMain_NotSaved()
        {
            // Arrange
            const string inputName1 = "P1";
            const string inputName2 = "T1";
            const string inputName3 = "V2"; // in gaz
            const string gazName1 = "P1";
            const string gazName2 = "T1";
            const string gazName3 = "V1"; // not allowed

            // gazetteer data - use test data 1
            GazetteerNames gazetteerNames = new GazetteerNames(
                GazetteerTestData.TestData1());

            // no existing saved matches
            var mock = MockRepository.GenerateMock<IMatchProvider>();
            MatchedNames matchedNames = new MatchedNames(mock);

            // input
            Location inputLocation = new Location(inputName1, inputName2, inputName3);

            // match from gazetteer
            Location gazetteerLocation = new Location(gazName1, gazName2, gazName3);

            // Act
            try
            {
                matchedNames.SaveMatch(inputLocation, gazetteerLocation, gazetteerNames);
            }
            catch (Exception)
            {
                //ignore the exception for this test
            }

            // Assert
            AssertNoSavesCalled(mock);
        }
        public void SaveMatch_InputLevel3ExistsInGazAsMain_ExceptionThrown()
        {
            // Arrange
            const string inputName1 = "P1";
            const string inputName2 = "T1";
            const string inputName3 = "V2"; // in gaz
            const string gazName1 = "P1";
            const string gazName2 = "T1";
            const string gazName3 = "V1"; // not allowed

            // gazetteer data - use test data 1
            GazetteerNames gazetteerNames = new GazetteerNames(
                GazetteerTestData.TestData1());

            // no existing saved matches
            MatchedNames matchedNames = new MatchedNames(MatchProviderStub.EmptyStub());

            // input
            Location inputLocation = new Location(inputName1, inputName2, inputName3);

            // match from gazetteer
            Location gazetteerLocation = new Location(gazName1, gazName2, gazName3);

            // Act
            matchedNames.SaveMatch(inputLocation, gazetteerLocation, gazetteerNames);

            // Assert
            // exception thrown
        }
        public void SaveMatch_InputLevel1IsAltEquivalentToMatch_Level2And3Saved()
        {
            // Arrange
            const string inputName1 = "P1A";
            const string inputName2 = "T1x";
            const string inputName3 = "V1x";
            const string gazName1 = "P1"; // ignore as is equivalent
            const string gazName2 = "T1"; // valid match
            const string gazName3 = "V1"; // valid match

            // gazetteer data - use test data 1
            GazetteerNames gazetteerNames = new GazetteerNames(
                GazetteerTestData.TestData1());

            // no existing saved matches
            var mock = MockRepository.GenerateMock<IMatchProvider>();
            MatchedNames matchedNames = new MatchedNames(mock);

            // input
            Location inputLocation = new Location(inputName1, inputName2, inputName3);

            // match from gazetteer
            Location gazetteerLocation = new Location(gazName1, gazName2, gazName3);

            // Act
            matchedNames.SaveMatch(inputLocation, gazetteerLocation, gazetteerNames);

            // Assert
            mock.AssertWasNotCalled(
                x => x.SaveMatchLevel1(Arg<string>.Is.Anything, Arg<string>.Is.Anything));
            mock.AssertWasCalled(x => x.SaveMatchLevel2(inputName2, gazName1, gazName2));
            mock.AssertWasCalled(
                x => x.SaveMatchLevel3(inputName3, gazName1, gazName2, gazName3));
        }
        public void SaveMatch_InputContains1ValidLevel_MatchSaved()
        {
            // Arrange
            const string inputName1 = "P1x";
            const string gazName1 = "P1"; // main value in gaz

            // gazetteer data - use test data 1
            GazetteerNames gazetteerNames = new GazetteerNames(
                GazetteerTestData.TestData1());

            //match provider
            var mock = MockRepository.GenerateMock<IMatchProvider>();
            MatchedNames matchedNames = new MatchedNames(mock);

            // input
            Location inputLocation = new Location(inputName1);

            // match from gazetteer
            Location gazetteerLocation = new Location(gazName1);

            // Act
            matchedNames.SaveMatch(inputLocation, gazetteerLocation, gazetteerNames);

            // Assert
            mock.AssertWasCalled(x => x.SaveMatchLevel1(inputName1, gazName1));
            mock.AssertWasNotCalled(
                x => x.SaveMatchLevel2(
                    Arg<string>.Is.Anything,
                    Arg<string>.Is.Anything,
                    Arg<string>.Is.Anything));
            mock.AssertWasNotCalled(
                x => x.SaveMatchLevel3(
                    Arg<string>.Is.Anything,
                    Arg<string>.Is.Anything,
                    Arg<string>.Is.Anything,
                    Arg<string>.Is.Anything));
        }
        private static void SaveMatchWithGazetteerTestData1(
            string inputName1,
            string inputName2,
            string inputName3,
            string gazName1,
            string gazName2,
            string gazName3)
        {
            // Arrange
            // gazetteer data - use test data 1
            GazetteerNames gazetteerNames = new GazetteerNames(
                GazetteerTestData.TestData1());

            // no existing saved matches
            MatchedNames matchedNames = new MatchedNames(MatchProviderStub.EmptyStub());

            // input
            Location inputLocation = new Location(inputName1, inputName2, inputName3);

            // match from gazetteer
            Location gazetteerLocation = new Location(gazName1, gazName2, gazName3);

            // Act
            matchedNames.SaveMatch(inputLocation, gazetteerLocation, gazetteerNames);
        }
Пример #10
0
        public void SaveMatch_MatchIsBlank_NotSaved()
        {
            // Arrange
            const string inputName1 = "P1x";
            const string inputName2 = "T1x";
            const string inputName3 = "V1x";
            const string gazName1 = "";
            const string gazName2 = "";
            const string gazName3 = "";

            // Arrange
            // gazetteer data - use test data 1
            GazetteerNames gazetteerNames = new GazetteerNames(
                GazetteerTestData.TestData1());

            //match provider
            var mock = MockRepository.GenerateMock<IMatchProvider>();
            MatchedNames matchedNames = new MatchedNames(mock);

            // input
            Location inputLocation = new Location(inputName1, inputName2, inputName3);

            // match from gazetteer
            Location gazetteerLocation = new Location(gazName1, gazName2, gazName3);

            // Act
            matchedNames.SaveMatch(inputLocation, gazetteerLocation, gazetteerNames);

            // Assert
            AssertNoSavesCalled(mock);
        }