Example #1
0
        public int FornameFirstCharacterCount(char forenameFirstCharacter)
        {
            int           totalOccurance = 0;
            List <string> InvalidNames   = new List <string>();

            ///TODO Move in AsynTask future work for better performance etc

            AddToCandidateDictionary(CandidateRepo.RegisteredCandidatesSource1());
            AddToCandidateDictionary(CandidateRepo.RegisteredCandidatesSource2());
            AddToCandidateDictionary(FileService.ReadFileContent("Source3.txt"));

            foreach (var item in CandidateNames)
            {
                var fullname = item.Key;

                if (ValidationService.IsValid(fullname))
                {
                    totalOccurance += CounterService.CountOccurance(forenameFirstCharacter, fullname);
                }
                else
                {
                    InvalidNames.Add(fullname);
                }
            }

            if (InvalidNames.Count > 0)
            {
                FileService.WriteFile($"WrongName{DateTime.UtcNow.ToFileTime()}.txt", InvalidNames.ToArray());
            }

            return(totalOccurance);
        }
        public void CountOccurance_Success()
        {
            //Arrange
            Letter = 'a';
            var expectedResult = 3;

            //Act
            var actualOccurance = CounterService.CountOccurance(Letter, FullName);

            //Assert
            Assert.AreEqual(expectedResult, actualOccurance);
        }