public static Dictionary <AddressCorrectness, Statistics> Calculate(List <string> states, string correctState, StatisticsOfCorrectAddress statsCorrectAddr, StatisticsOfIncorrectAddress statsIncorrectAddr, Dictionary <AddressCorrectness, Statistics> results) { if (TestRunner.Counter <= 70) { results[AddressCorrectness.Correct] = AnaylyzeForCorrectAddress(states, correctState, statsCorrectAddr); } if (TestRunner.Counter >= 70) { results[AddressCorrectness.Incorrect] = AnaylyzeForIncorrectAddress(states, correctState, statsIncorrectAddr); } return(results); }
public static void SearchStreetZipCodesFromAPIAndWrite(IStreetLookUp streetlookup, List <StreetLookupInput> textResource, StreamWriter writer, CsvWriter csvWriter) { Counter = 0; StatisticsOfCorrectAddress statsCorrectAddr = new StatisticsOfCorrectAddress(); StatisticsOfIncorrectAddress statsIncorrectAddr = new StatisticsOfIncorrectAddress(); Dictionary <AddressCorrectness, Statistics> results = new Dictionary <AddressCorrectness, Statistics>(); foreach (var data in textResource) { var states = streetlookup.GetStatesSearchByStreetAndZip(data.StreetName, data.ZipCode); var validation = streetlookup.ValidateStreetAndZip(data.StreetName, data.ZipCode); ConsoleStreetPrint.Data(streetlookup.GetNameOfAPI(), validation, states, data.StateCode); Counter += 1; results = MatchedStatistic.Calculate(states, data.StateCode, statsCorrectAddr, statsIncorrectAddr, results); } StatisticsToCsvFile.Write(streetlookup.GetNameOfAPI(), results, writer, csvWriter); }
private static StatisticsOfIncorrectAddress AnaylyzeForIncorrectAddress(List <string> states, string correctState, StatisticsOfIncorrectAddress statsIncorrectAddr) { if (states.Contains(correctState)) { statsIncorrectAddr.NumberOfMatched += 1; } statsIncorrectAddr.PercentageOfMatched = (statsIncorrectAddr.NumberOfMatched / 30) * 100; return(statsIncorrectAddr); }