예제 #1
0
        private void RunMatcher_OnClick(object sender, EventArgs e)
        {
            MatchResultsListBox.Items.Clear();
            LogPrintListBox.Items.Clear();

            if (InputFilenameTextBox.Text.Length > 0)
            {
                List <MatchResult> matchList = new List <MatchResult>();
                RunMatcherButton.Enabled = false;
                Logger.Info("Starting matching process...");

                FileHandler.FileType fileType = FileHandler.FileType.JSON;
                if (XmlRadioButton.Checked)
                {
                    fileType = FileHandler.FileType.XML;
                }

                if (PersonMatcher.LoadPersonsFromFile(InputFilenameTextBox.Text, fileType))
                {
                    matchList = PersonMatcher.FindAllMatches();
                }

                Logger.Info("Matching process completed.");
            }
            else
            {
                Logger.Warn("Please select a file");
            }

            RunMatcherButton.Enabled = true;
        }
예제 #2
0
        private void SaveToFile_Clicked(object sender, EventArgs e)
        {
            FileHandler.FileType type = FileHandler.FileType.JSON;
            if (XmlOuput.Checked)
            {
                type = FileHandler.FileType.XML;
            }

            PersonMatcher.SaveMatchesToFile(OutputFilename.Text, type);
        }
예제 #3
0
        public void CanMatch()
        {
            Person w1 = new Person
            {
                BirthDate = new DateTime(1990, 1, 1),
                EyesColor = EyesColor.Blue,
                Height    = 160
            };

            Person m1 = new Person
            {
                BirthDate = new DateTime(1993, 1, 1),
                EyesColor = EyesColor.Blue,
                Height    = 169
            };

            Person w2 = new Person
            {
                BirthDate = new DateTime(1990, 1, 1),
                EyesColor = EyesColor.Blue,
                Height    = 160
            };

            Person m2 = new Person
            {
                BirthDate = new DateTime(1996, 1, 1),
                EyesColor = EyesColor.Green,
                Height    = 171
            };

            var validators = new List <IPersonValidator> {
                new AgeValidator(), new HeightValidator(), new EyesColorValidator()
            };

            PersonMatcher matcher1 = new PersonMatcher(validators)
            {
                Woman = w1, Man = m1
            };
            PersonMatcher matcher2 = new PersonMatcher(validators)
            {
                Woman = w2, Man = m2
            };

            Assert.True(matcher1.Matched());
            Assert.False(matcher2.Matched());
        }