private void UserPatientCareInfo_IsAcceptingNewPatients() { var oldValue = HttpUtility.HtmlDecode(ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.newPatients.ToString())); if (!string.IsNullOrEmpty(oldValue)) { if (oldValue.ToUpper() == "NA") { // See ticket #568 oldValue = "No"; } else if (oldValue.ToUpper() == "ICO") { // ticket #612 - InPatients Only - restricted yes oldValue = "Yes"; } } var newValue = string.Empty; if (this.newDataPatientCare != null && this.newDataPatientCare.AcceptingNewPatientsStatus != null) { newValue = this.newDataPatientCare.AcceptingNewPatientsStatus.Name; } this.CompareAndLog_Test( EnumTestUnitNames.UserPatientCareInfo_IsAcceptingNewPatients, "Comparing Accepting New Patients", oldValue, newValue); }
private void UserContactLocationInfo_Addresses_Geo(IEnumerable <XElement> oldServiceNodes, HashSet <GeoPoint> newValues) { var watch = new Stopwatch(); watch.Start(); List <string> oldValues = new List <string>(); oldValues.AddRange(ParsingHelper.ParseUnstructuredListOfValues(oldServiceNodes, EnumOldServiceFieldsAsKeys.location.ToString(), EnumOldServiceFieldsAsKeys.latitude.ToString())); oldValues.AddRange(ParsingHelper.ParseUnstructuredListOfValues(oldServiceNodes, EnumOldServiceFieldsAsKeys.location.ToString(), EnumOldServiceFieldsAsKeys.longitude.ToString())); HashSet <string> roundedOldValues = new HashSet <string>(oldValues.Where(x => !string.IsNullOrEmpty(x)).Select(x => Math.Round(Double.Parse(x), 0).ToString())); HashSet <string> roundedNewValues = new HashSet <string>(); if (newValues != null) { foreach (var value in newValues) { try { roundedNewValues.Add(Math.Round((double)value.Latitude, 0).ToString()); } catch (Exception) { } try { roundedNewValues.Add(Math.Round((double)value.Longitude, 0).ToString()); } catch (Exception) { } } } CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_Addresses_Geo, "Comparing Geo Location Data", roundedOldValues, roundedNewValues, watch); }
private void UserResearchCareInfo_Meshes() { var oldValuesMerged = HttpUtility.HtmlDecode(ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.mesh.ToString())); // data is originally in an HTML list oldValuesMerged = oldValuesMerged.Replace("</li><li>", ","); oldValuesMerged = oldValuesMerged.Replace("<ul><li>", ""); oldValuesMerged = oldValuesMerged.Replace("</li></ul>", ""); var oldValues = ParsingHelper.StringToList(oldValuesMerged, ','); var newValues = new HashSet <string>(); if (newData != null && newData.Meshes != null && newData.Meshes.Count() > 0) { foreach (var entry in newData.Meshes) { newValues.Add(entry.Keyword); } } this.CompareAndLog_Test( EnumTestUnitNames.UserResearchInfo_Meshes, "Comparing Research Meshes", oldValues, newValues); }
private LogManager() { // the order here is quite important because this is implicitly the expectation of the templates AllTestNames = new SortedSet <EnumTestUnitNames>(); foreach (var testName in (EnumTestUnitNames[])Enum.GetValues(typeof(EnumTestUnitNames))) { AllTestNames.Add(testName); } IdentifiedBehaviorsDescriptions = new Dictionary <EnumIdentifiedDataBehavior, string>(); foreach (var behavior in (EnumIdentifiedDataBehavior[])Enum.GetValues(typeof(EnumIdentifiedDataBehavior))) { IdentifiedBehaviorsDescriptions.Add(behavior, ParsingHelper.GetDescription(behavior)); } NoWarningNorErrorHappenedFlag_ByOldId = new Dictionary <int, bool>(); countSeverityTypeOccurences = new Dictionary <EnumTestUnitNames, Dictionary <EnumResultSeverityType, int> >(); countDataBehaviorOccurences = new Dictionary <EnumTestUnitNames, Dictionary <EnumIdentifiedDataBehavior, int> >(); durations = new Dictionary <EnumTestUnitNames, HashSet <TimeSpan> >(); foreach (var testName in AllTestNames) { durations.Add(testName, new HashSet <TimeSpan>()); } durationByProfile = new HashSet <TimeSpan>(); detailedReportsWriters = new Dictionary <EnumTestUnitNames, HtmlTextWriter>(); StatsCountTotalOldIds = 0; StatsCountProfilesIgnored = 0; }
private void UserContactLocationInfo_UserAddress_ZipCodes_Test(IEnumerable <XElement> oldServiceNodes, HashSet <string> newValues) { var watch = new Stopwatch(); watch.Start(); HashSet <string> oldValues = ParsingHelper.ParseUnstructuredListOfValues(oldServiceNodes, EnumOldServiceFieldsAsKeys.zipCode.ToString()); CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_Addresses_ZipCodes, "Comparing Address Zip Code(s)", oldValues, newValues, watch); }
private void UserEducationTrainingInfo_Education() { var oldValues = ParsingHelper.ParseStructuredListOfValues( this.OldDataNodes, EnumOldServiceFieldsAsKeys.education.ToString(), new EnumOldServiceFieldsAsKeys[] { EnumOldServiceFieldsAsKeys.degree, EnumOldServiceFieldsAsKeys.institution, EnumOldServiceFieldsAsKeys.gradYear }); var newValues = new HashSet <Dictionary <EnumOldServiceFieldsAsKeys, string> >(); Dictionary <EnumOldServiceFieldsAsKeys, string> properties; if (this.newDataEducation != null) { foreach (var newValue in this.newDataEducation) { properties = new Dictionary <EnumOldServiceFieldsAsKeys, string>(); try { properties.Add(EnumOldServiceFieldsAsKeys.degree, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.DegreeAwarded))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.degree, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.institution, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Institution))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.institution, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.gradYear, String.Format("{0:yyyy}", newValue.DateAwarded)); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.gradYear, string.Empty); } newValues.Add(properties); } } this.CompareAndLog_Test(EnumTestUnitNames.UserEducationTrainingInfo_Education, "Comparing Education(s)", oldValues, newValues); }
private void UserGeneralInfo_CountCVs_Test() { HashSet <string> oldValues = ParsingHelper.ParseUnstructuredListOfValues(this.OldDataNodes, EnumOldServiceFieldsAsKeys.cv.ToString(), EnumOldServiceFieldsAsKeys.fileName.ToString()); string oldValue = oldValues.Count().ToString(); string newValue = string.Empty; try { newValue = (!string.IsNullOrEmpty(newData.CvUrl)?"1":"0"); } catch (Exception) { } this.CompareAndLog_Test(EnumTestUnitNames.UserGeneralInfo_CVs_Count, "Count CVs listed", oldValue, newValue); }
private void UserPatientCareInfo_ContainsData() { var oldValuePopulated = !string.IsNullOrWhiteSpace(ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.newPatients.ToString())); var oldValuePopulated2 = !string.IsNullOrWhiteSpace(ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.patientsGroups.ToString())); var oldValuePopulated3 = !string.IsNullOrWhiteSpace(ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.cancersTreated.ToString())); var oldPatientCarePopulated = oldValuePopulated || oldValuePopulated2 || oldValuePopulated3; var newPatientCarePopulated = (this.newDataPatientCare != null); this.CompareAndLog_Test( EnumTestUnitNames.UserPatientCareInfo_IsPopulated, "Comparing PatientCare data populated", oldPatientCarePopulated.ToString(), newPatientCarePopulated.ToString()); }
private void UserContactLocationInfo_UserAddress_IsMailing_Test(IEnumerable <XElement> oldServiceNodes, HashSet <string> newValues) { var watch = new Stopwatch(); watch.Start(); StringBuilder mailingAddress = new StringBuilder(); mailingAddress.Append(ParsingHelper.ParseSingleValue(oldServiceNodes, EnumOldServiceFieldsAsKeys.mailingAddress1.ToString())); mailingAddress.Append(" "); mailingAddress.Append(ParsingHelper.ParseSingleValue(oldServiceNodes, EnumOldServiceFieldsAsKeys.mailingAddress2.ToString())); var oldValues = new HashSet <string>(); oldValues.Add(mailingAddress.ToString()); CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_Addresses_IsMailing, "Comparing Mailing Address", oldValues, newValues, watch); }
private void UserPatientCareInfo_IsSeeingPatientType() { var oldValuesMerged = HttpUtility.HtmlDecode(ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.patientsGroups.ToString())); var oldValues = ParsingHelper.StringToList(oldValuesMerged, ','); var newValues = new HashSet<string>(); if (this.newDataPatientCare != null) { if (this.newDataPatientCare.IsSeeingAdults) { newValues.Add("Adult"); } } if (this.newDataPatientCare != null) { if (this.newDataPatientCare.IsSeeingChildren) { newValues.Add("Child"); } } if (this.newDataPatientCare != null) { if (this.newDataPatientCare.IsSeeingAdolescents) { newValues.Add("Adolescent"); } } if (this.newDataPatientCare != null) { if (this.newDataPatientCare.IsSeeingGeriatrics) { newValues.Add("Geriatric"); } } this.CompareAndLog_Test( EnumTestUnitNames.UserPatientCareInfo_IsSeeingPatientType, "Comparing Patient Type(s)", oldValues, newValues); }
private void UserResearchInfo_PublicHealthKeywords() { HashSet <string> newValues = new HashSet <string>();; try { if (this.newData != null && this.newData.PublicHealths != null) { newValues = new HashSet <string>(newData.PublicHealths.Where(x => x != null).Select(x => HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(x.Keyword)))); } } catch (Exception) { } this.CompareAndLog_Test( EnumTestUnitNames.UserResearchInfo_PublicHealthKeywords, "Comparing Public Health Keyword(s)", ParsingHelper.ParseUnstructuredListOfValues(ParsingHelper.ParseListNodes(this.OldDataNodes, EnumOldServiceFieldsAsKeys.publicHealthKeywords.ToString()), EnumOldServiceFieldsAsKeys.keyword.ToString(), EnumOldServiceFieldsAsKeys.name.ToString()), newValues); }
private HashSet <string> UserPublicationInfo_Titles() { HashSet <string> newValues; if (this.newData != null) { newValues = new HashSet <string>(newData.Where(x => x != null).Select(x => HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(x.Publication.Title)))); } else { newValues = new HashSet <string>(); } this.CompareAndLog_Test( EnumTestUnitNames.UserPublicationInfo_Titles, "Comparing Publication Title(s)", ParsingHelper.ParseUnstructuredListOfValues(this.OldDataNodes, EnumOldServiceFieldsAsKeys.featuredPublication.ToString(), EnumOldServiceFieldsAsKeys.titleName.ToString()), newValues); return(newValues); }
private void UserGeneralInfo_All_EduProfSuffixes() { string oldValuePart1 = ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.degree.ToString()); string oldValuePart2 = ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.professionalSuffix.ToString()); HashSet <string> oldValues = ParsingHelper.StringToList(oldValuePart1, ','); oldValues = ParsingHelper.StringToList(oldValuePart2, ',', oldValues); HashSet <string> oldValuesToExpectedNewValues = new HashSet <string>(); foreach (var oldValue in oldValues) { // present old value as the value expected to be returned by the new service in order to pass the test: ticket #467 var oldValueToExpectedNewValue = this.suffixMapping.Where(n => n.Key.ToUpper() == oldValue.Trim().ToUpper()).Select(n => n.Value); if (oldValueToExpectedNewValue != null && oldValueToExpectedNewValue.Count() > 0) { oldValuesToExpectedNewValues.Add(oldValueToExpectedNewValue.First()); } else { // value not mapped oldValuesToExpectedNewValues.Add(oldValue); } } HashSet <string> newValues = new HashSet <string>(); try { if (newData.Titles.Count() > 0) { foreach (var suffix in newData.Suffixes) { newValues.Add(HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(suffix.Name))); } } } catch (Exception) { } this.CompareAndLog_Test(EnumTestUnitNames.UserGeneralInfo_All_EduProfSuffixes, "Comparing list of Suffix(es)", oldValuesToExpectedNewValues, newValues); }
private void UserGeneralInfo_LanguageUsers_Test() { var oldValues = ParsingHelper.ParseUnstructuredListOfValues(this.OldDataNodes, EnumOldServiceFieldsAsKeys.language.ToString(), EnumOldServiceFieldsAsKeys.languageName.ToString()); var newValues = new HashSet <string>(); try { if (newData.UserLanguages.Count() > 0) { foreach (var language in newData.UserLanguages) { newValues.Add(HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(language.Language.Name))); } } } catch (Exception) { } this.CompareAndLog_Test(EnumTestUnitNames.UserGeneralInfo_Languages, "Comparing LanguageUser(s)", oldValues, newValues); }
private void UserPublicationInfo_Description() { var newValues = new HashSet <string>(); try { if (this.newData != null) { newValues = new HashSet <string>(this.newData.Where(x => x != null).Select(x => HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(x.Publication.Citation)))); } } catch (Exception) { } this.CompareAndLog_Test( EnumTestUnitNames.UserPublicationInfo_Citations, "Comparing Publication Citation(s)", ParsingHelper.ParseUnstructuredListOfValues(this.OldDataNodes, EnumOldServiceFieldsAsKeys.featuredPublication.ToString(), EnumOldServiceFieldsAsKeys.description.ToString()), newValues); }
private void UserEducationTrainingInfo_CancersTreated() { var oldValuesMerged = ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.cancersTreated.ToString()); var oldValues = ParsingHelper.StringToList(oldValuesMerged, ','); var newValues = new HashSet<string>(); if (this.newDataPatientCare != null && this.newDataPatientCare.CancersTreated != null) { foreach (var newValueEntry in this.newDataPatientCare.CancersTreated) { if (!string.IsNullOrEmpty(newValueEntry.Name)) { newValues.Add(HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValueEntry.Name))); } } } this.CompareAndLog_Test(EnumTestUnitNames.UserPatientCareInfo_CancersTreated, "Comparing Cancer(s) Treated", oldValues, newValues); }
private void UserGeneralInfo_CheckUserProfileImageLink_Test() { HashSet <string> oldValues = ParsingHelper.ParseUnstructuredListOfValues(this.OldDataNodes, EnumOldServiceFieldsAsKeys.photoURL.ToString()); string oldValue = oldValues.Count().ToString(); string newValue = string.Empty; if (newData.ProfileImage != null && !string.IsNullOrEmpty(newData.ProfileImage.Url)) { HttpWebResponse response = null; var request = (HttpWebRequest)WebRequest.Create(newData.ProfileImage.Url); request.Method = "HEAD"; try { response = (HttpWebResponse)request.GetResponse(); oldValue = "Exists"; newValue = "Exists"; } catch (WebException ex) { /* A WebException will be thrown if the status of the response is not `200 OK` */ oldValue = "FailedRetrieve"; newValue = "Exists"; } finally { // Don't forget to close your response. if (response != null) { response.Close(); } } } else { oldValue = "None"; newValue = "None"; } this.CompareAndLog_Test(EnumTestUnitNames.UserGeneralInfo_ProfileImage_Link, "Check File Exists at Profile Image URL", oldValue, newValue); }
protected override void RunAllSingleTests() { var oldDataLabWebsites = ParsingHelper.ParseListNodes(this.OldDataNodes, EnumOldServiceFieldsAsKeys.labWebsite.ToString()); UserContactLocationInfo_LabWebsites_Names_Test(oldDataLabWebsites, new HashSet <string>(this.newDataLabWebsite.Select(x => HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(x.LabName))))); UserContactLocationInfo_LabWebsites_Links_Test(oldDataLabWebsites, new HashSet <string>(this.newDataLabWebsite.Select(x => HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(x.LabUrl))))); UserContactLocationInfo_Addresses_Test(); var oldAddressesWithoutMailing = ParsingHelper.ParseListNodes(this.OldDataNodes, EnumOldServiceFieldsAsKeys.location.ToString()); var oldAddresses = ParsingHelper.ParseListNodes(this.OldDataNodes, EnumOldServiceFieldsAsKeys.mailing.ToString(), oldAddressesWithoutMailing.ToList(), true); UserContactLocationInfo_Addresses_Geo(oldAddressesWithoutMailing, new HashSet <GeoPoint>(this.newDataUserAddress.Select(x => x.Address.Building.GeoPoint))); UserContactLocationInfo_UserAddress_StreetAddress_Test(oldAddresses, new HashSet <string>(this.newDataUserAddress.Select(x => HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(x.Address.Building.StreetAddress))))); UserContactLocationInfo_UserAddress_ZipCodes_Test(oldAddresses, new HashSet <string>(this.newDataUserAddress.Select(x => x.Address.Building.Locality.PostalCode))); UserContactLocationInfo_UserAddress_Phones_Test(oldAddresses, this.newDataUserAddress); UserContactLocationInfo_UserAddress_IsMailing_Test(oldAddresses, new HashSet <string>(this.newDataUserAddress.Select(x => HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(x.Address.Building.StreetAddress)))));//.newDataUserAddress.Where(x => x.Address.AddressType == true) ComputeOverallSeverity(); }
private void UserContactLocationInfo_UserAddress_StreetAddress_Test(IEnumerable <XElement> oldServiceNodes, HashSet <string> newValues) { var watch = new Stopwatch(); watch.Start(); HashSet <string> oldValues = ParsingHelper.ParseUnstructuredListOfValues(oldServiceNodes, EnumOldServiceFieldsAsKeys.addressLine1.ToString()); StringBuilder mailingAddress = new StringBuilder(); mailingAddress.Append(ParsingHelper.ParseSingleValue(oldServiceNodes, EnumOldServiceFieldsAsKeys.mailingAddress1.ToString())); mailingAddress.Append(" "); mailingAddress.Append(ParsingHelper.ParseSingleValue(oldServiceNodes, EnumOldServiceFieldsAsKeys.mailingAddress2.ToString())); if (!string.IsNullOrWhiteSpace(mailingAddress.ToString())) { oldValues.Add(mailingAddress.ToString()); } CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_Addresses_StreetAddress, "Comparing Address StreetInfo(s)", oldValues, newValues, watch); }
private void UserContactLocationInfo_UserAddress_Phones_Test(IEnumerable <XElement> oldServiceNodes, IEnumerable <UserAddress> newServiceNodes) { // phone numbers are specific to a UserAddress which is the equivalent of the Location in the old service // the locationName became the OfficeName var watch = new Stopwatch(); watch.Start(); var oldValues = new List <string>(); oldValues.AddRange(ParsingHelper.ParseUnstructuredListOfValues(oldServiceNodes, EnumOldServiceFieldsAsKeys.location.ToString(), EnumOldServiceFieldsAsKeys.phoneNumber.ToString())); oldValues.AddRange(ParsingHelper.ParseUnstructuredListOfValues(oldServiceNodes, EnumOldServiceFieldsAsKeys.location.ToString(), EnumOldServiceFieldsAsKeys.phone2Number.ToString())); var newValues = new List <string>(); var allPhones = newServiceNodes.Select(x => x.Phones); foreach (var list in allPhones) { newValues.AddRange(list.Select(x => ParsingHelper.FormatPhoneNumber(x.Number))); } CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_Addresses_Phones, "Comparing Address Phone Number(s)", new HashSet <string>(oldValues.Where(x => !string.IsNullOrWhiteSpace(x))), new HashSet <string>(newValues), watch); }
//private void UserGeneralInfo_AltFirstName_Test() //{ // var watch = new Stopwatch(); // watch.Start(); // var resultReport = new ResultReport(this.UserId, this.OldId, EnumTestUnitNames.UserGeneralInfo_AltFirstName, "Comparing AltFirstName (if needed)"); // string oldValue = ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.firstname.ToString()); // var compareStrategy = new CompareStrategyFactory(oldValue, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newData.FirstName)), resultReport); // compareStrategy.Investigate(); // if (resultReport.Severity != EnumResultSeverityType.SUCCESS) // { // resultReport = new ResultReport(this.UserId, this.OldId, EnumTestUnitNames.UserGeneralInfo_AltFirstName, "Comparing AltFirstName (if needed)"); // oldValue = ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.firstname.ToString()); // compareStrategy = new CompareStrategyFactory(oldValue, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newData.AltFirstName)), resultReport); // compareStrategy.Investigate(); // } // watch.Stop(); // resultReport.Duration = watch.Elapsed; // this.DetailedResults.Add(resultReport.TestName, resultReport); // LogManager.Instance.LogTestResult(this.Container.BuildOldServiceFullURL(this.OldId), // this.BuildNewServiceURL(this.PageName), // resultReport); //} //private void UserGeneralInfo_AltSuffixName_Test() //{ // var watch = new Stopwatch(); // watch.Start(); // var resultReport = new ResultReport(this.UserId, this.OldId, EnumTestUnitNames.UserGeneralInfo_AltSuffixName, "Comparing Alt SuffixName (if needed)"); // string oldValue = ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.suffix.ToString()); // // present old value as the value expected to be returned by the new service in order to pass the test: ticket #467 // var oldValueToExpectedNewValue = this.suffixMapping.Where(n => n.Key.ToUpper() == oldValue.Trim().ToUpper()).Select(n => n.Value); // if (oldValueToExpectedNewValue != null && oldValueToExpectedNewValue.Count() > 0) // { // oldValue = oldValueToExpectedNewValue.First(); // } // var compareStrategy = new CompareStrategyFactory(oldValue, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newData.Suffix)), resultReport); // compareStrategy.Investigate(); // if (resultReport.Severity != EnumResultSeverityType.SUCCESS) // { // resultReport = new ResultReport(this.UserId, this.OldId, EnumTestUnitNames.UserGeneralInfo_AltSuffixName, "Comparing Alt SuffixName (if needed)"); // oldValue = ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.suffix.ToString()); // // present old value as the value expected to be returned by the new service in order to pass the test: ticket #467 // oldValueToExpectedNewValue = this.suffixMapping.Where(n => n.Key.ToUpper() == oldValue.Trim().ToUpper()).Select(n => n.Value); // if (oldValueToExpectedNewValue != null && oldValueToExpectedNewValue.Count() > 0) // { // oldValue = oldValueToExpectedNewValue.First(); // } // compareStrategy = new CompareStrategyFactory(oldValue, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newData.AltSuffix)), resultReport); // compareStrategy.Investigate(); // } // watch.Stop(); // resultReport.Duration = watch.Elapsed; // this.DetailedResults.Add(resultReport.TestName, resultReport); // LogManager.Instance.LogTestResult(this.Container.BuildOldServiceFullURL(this.OldId), // this.BuildNewServiceURL(this.PageName), // resultReport); //} //private void UserGeneralInfo_AltMiddleName_Test() //{ // var watch = new Stopwatch(); // watch.Start(); // var resultReport = new ResultReport(this.UserId, this.OldId, EnumTestUnitNames.UserGeneralInfo_AltMiddleName, "Comparing AltMiddleName (if needed)"); // string oldValue = ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.middle.ToString()); // if (string.IsNullOrEmpty(oldValue)) // { // oldValue = "False"; // } // var compareStrategy = new CompareStrategyFactory(oldValue, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newData.MiddleName)), resultReport); // compareStrategy.Investigate(); // if (resultReport.Severity != EnumResultSeverityType.SUCCESS) // { // resultReport = new ResultReport(this.UserId, this.OldId, EnumTestUnitNames.UserGeneralInfo_AltMiddleName, "Comparing AltMiddleName (if needed)"); // oldValue = ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.middle.ToString()); // compareStrategy = new CompareStrategyFactory(oldValue, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newData.AltMiddleName)), resultReport); // compareStrategy.Investigate(); // } // watch.Stop(); // resultReport.Duration = watch.Elapsed; // this.DetailedResults.Add(resultReport.TestName, resultReport); // LogManager.Instance.LogTestResult(this.Container.BuildOldServiceFullURL(this.OldId), // this.BuildNewServiceURL(this.PageName), // resultReport); //} private void UserGeneralInfo_Titles_Test() { HashSet <string> oldValues = ParsingHelper.ParseUnstructuredListOfValues(this.OldDataNodes, EnumOldServiceFieldsAsKeys.title.ToString(), EnumOldServiceFieldsAsKeys.titleName.ToString()); HashSet <string> newValues = new HashSet <string>(); try { if (newData.Titles.Count() > 0) { foreach (var title in newData.Titles) { if (!string.IsNullOrEmpty(title.Name)) { newValues.Add(HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(title.Name))); } } } } catch (Exception) { } this.CompareAndLog_Test(EnumTestUnitNames.UserGeneralInfo_Titles, "Comparing Title(s)", oldValues, newValues); }
public override void RunAllTests() { //init all loop variables string oldServiceURL; string oldServiceXMLOutput; string errorType = string.Empty; string errorMessage = string.Empty; OldIdList = new DatabaseFacade().ConnectToDataSourceAndRetrieveOldIds("a30"); var singleProfileWatch = new Stopwatch(); var testingDurationWatch = new Stopwatch(); var oldServiceDataWatch = new Stopwatch(); var newServiceDataWatch = new Stopwatch(); testingDurationWatch.Start(); LogManager.Instance.StartWritingReports(); if (TestSuiteUser.IsDebugMode) { OldIdList = new HashSet <int>() { 12386392, 12789020, 10254830, 10345899, 10643722, 10356439, 13087115, 10098855, 10445859, 12445467, 10044421, 11842460, 10273683, 11228709, 12528002, 10410346, 10071485, 10934133, 12149599, 12641341, 10151776, 10290564, 11091604, 11472557, 12149599, 13132301, 10146455, 13157019, 10646102, 12192949, 10106216, 12268225, 11161032, 11832447, 11436806, 10736848 }; } bool keepGoing = true; //loop on the list of all OldIds retrieved from the old database foreach (int OldId in OldIdList) //Parallel.ForEach(OldIdList, OldId => { if (keepGoing) { oldServiceXMLOutput = string.Empty; System.Diagnostics.Debug.WriteLine(OldId); System.Console.Out.WriteLine(OldId); LogManager.Instance.StatsCountTotalOldIds++; if (false && LogManager.Instance.StatsCountTotalOldIds > 1000) { keepGoing = false; } singleProfileWatch.Start(); if (LogManager.Instance.StatsCountTotalOldIds % MaxProfilesForOneFile == 0) { // change to next output files LogManager.Instance.StartWritingReports(); } //go to the old service and retrieve the data oldServiceURL = this.BuildOldServiceFullURL(OldId); //Find a way to set the 'Timeout' property in Milliseconds. The old service can be slow. //we also need exception handling! oldServiceDataWatch.Start(); try { using (var webClient = new TimeoutExtendedWebClient()) { try { webClient.Encoding = System.Text.Encoding.UTF8; oldServiceXMLOutput = webClient.DownloadString(oldServiceURL); } catch (WebException we) { System.Diagnostics.Debug.WriteLine(we.StackTrace); System.Diagnostics.Debug.WriteLine("Trying to get data from old service for OldId " + OldId + " again"); try { oldServiceXMLOutput = webClient.DownloadString(oldServiceURL); } catch (WebException we2) { System.Diagnostics.Debug.WriteLine(we2.StackTrace); } } } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.StackTrace); System.Diagnostics.Debug.WriteLine("Some inactive profiles do not have the flag set in the old service. Likely to be the case here."); } oldServiceDataWatch.Stop(); var allTheTests = new HashSet <TestUnit>(); var allTheResults = new HashSet <ResultReport>(); XDocument oldServiceXMLOutputDocument = null; IEnumerable <XElement> oldData = null; UserBasicInfo newDataBasic = null; UserCompleteInfo newData = null; string pageName = string.Empty; int userId; if (!string.IsNullOrEmpty(oldServiceXMLOutput)) { try { oldServiceXMLOutputDocument = XDocument.Parse(oldServiceXMLOutput); oldData = oldServiceXMLOutputDocument.XPathSelectElements("/Faculty/facultyMember/*"); var rootDepthOnly = ParsingHelper.ParseListNodesOnlySameDepth(oldData, null); //} //catch (Exception e) //{ // System.Diagnostics.Debug.WriteLine(e.StackTrace); //} //try //{ bool isInactive = false; // there is a third state : "Read-Only", not used for the moment isInactive = (ParsingHelper.ParseSingleValue(oldData, "Inactive") == "Yes"); if (!isInactive) { TestUnit testUnit; IEnumerable <XElement> oldDataSubset = null; var usersClient = new UsersClient(); newServiceDataWatch.Start(); newDataBasic = usersClient.GetUserByOldId(OldId); newServiceDataWatch.Stop(); userId = newDataBasic.UserId; pageName = newDataBasic.PageName; // This service has to be called first because it will provided the User ID mapped to the OldId for the next calls. oldDataSubset = rootDepthOnly; testUnit = new TestUnitUserBasicInfo(this, newDataBasic); allTheTests.Add(testUnit); testUnit.ProvideData( OldId, oldDataSubset, -1, pageName); testUnit.RunAllTests(); oldDataSubset = null; newServiceDataWatch.Start(); newData = usersClient.GetUserCompleteByPageName(pageName); newServiceDataWatch.Stop(); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.title.ToString(), new List <XElement>(rootDepthOnly)); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.cv.ToString(), new List <XElement>(oldDataSubset)); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.language.ToString(), new List <XElement>(oldDataSubset)); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.department.ToString(), new List <XElement>(oldDataSubset)); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.treeDepartments.ToString(), new List <XElement>(oldDataSubset)); testUnit = new TestUnitUserGeneralInfo(this, newData); allTheTests.Add(testUnit); testUnit.ProvideData( OldId, oldDataSubset, userId, pageName); testUnit.RunAllTests(); oldDataSubset = null; oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.assistant.ToString()); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.labWebsite.ToString(), new List <XElement>(oldDataSubset)); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.location.ToString(), new List <XElement>(oldDataSubset)); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.mailing.ToString(), new List <XElement>(oldDataSubset), true); testUnit = new TestUnitUserContactLocationInfo(this, newData.LabWebsites, newData.UserAddresses); allTheTests.Add(testUnit); testUnit.ProvideData( OldId, oldDataSubset, userId, pageName); testUnit.RunAllTests(); oldDataSubset = null; oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.featuredPublication.ToString()); testUnit = new TestUnitUserPublicationInfo(this, newData.UserPublications); allTheTests.Add(testUnit); testUnit.ProvideData( OldId, oldDataSubset, userId, pageName); testUnit.RunAllTests(); oldDataSubset = null; oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.researchSummary.ToString()); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.researchOverview.ToString(), new List <XElement>(oldDataSubset)); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.publicHealthKeywords.ToString(), new List <XElement>(oldDataSubset)); testUnit = new TestUnitUserResearchInfo(this, newData.Research); allTheTests.Add(testUnit); testUnit.ProvideData( OldId, oldDataSubset, userId, pageName); testUnit.RunAllTests(); oldDataSubset = null; oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.education.ToString()); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.training.ToString(), new List <XElement>(oldDataSubset)); testUnit = new TestUnitUserEducationTrainingInfo(this, newData.Educations, newData.Trainings); allTheTests.Add(testUnit); testUnit.ProvideData( OldId, oldDataSubset, userId, pageName); testUnit.RunAllTests(); oldDataSubset = null; oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.professionalHonor.ToString()); oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.professionalService.ToString(), new List <XElement>(oldDataSubset)); testUnit = new TestUnitUserHonorServiceInfo(this, newData.Honors, newData.Services); allTheTests.Add(testUnit); testUnit.ProvideData( OldId, oldDataSubset, userId, pageName); testUnit.RunAllTests(); oldDataSubset = null; oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.boardCertification.ToString(), new List <XElement>(rootDepthOnly)); testUnit = new TestUnitUserPatientCareInfo(this, newData.BoardCertifications, newData.PatientCare); allTheTests.Add(testUnit); testUnit.ProvideData( OldId, oldDataSubset, userId, pageName); testUnit.RunAllTests(); oldDataSubset = null; oldDataSubset = ParsingHelper.ParseListNodes(oldData, EnumOldServiceFieldsAsKeys.treeDepartments.ToString()); testUnit = new TestUnitUserOrganization(this, newData.OrganizationsTree); allTheTests.Add(testUnit); testUnit.ProvideData( OldId, oldDataSubset, userId, pageName); testUnit.RunAllTests(); oldDataSubset = null; oldDataSubset = rootDepthOnly; testUnit = new TestUnitUserGeneralContact(this, newData.GeneralContact); allTheTests.Add(testUnit); testUnit.ProvideData( OldId, oldDataSubset, userId, pageName); testUnit.RunAllTests(); oldDataSubset = null; foreach (var test in allTheTests) { test.ComputerOverallResults(); allTheResults.UnionWith(test.DetailedResults.Values); // log only first occurence of error - enough to generate the warning if ((test.HttpErrorHappened || test.UnknownErrorHappened) && string.IsNullOrEmpty(errorMessage)) { errorMessage = test.ErrorMessage; if (test.HttpErrorHappened) { errorType = "HTTP"; } else { errorType = "UNKNOWN"; } } } } else { LogManager.Instance.StatsCountProfilesIgnored++; } } catch (Exception e) { System.Console.WriteLine(e.StackTrace); System.Diagnostics.Debug.WriteLine(e.StackTrace); System.Console.WriteLine(e.InnerException); System.Diagnostics.Debug.WriteLine(e.InnerException); } } else { System.Diagnostics.Debug.WriteLine("No data returned by old service for OldId " + OldId); System.Console.Out.WriteLine("No data returned by old service for OldId " + OldId); } singleProfileWatch.Stop(); LogManager.Instance.LogProfileResult(OldId, allTheResults, singleProfileWatch.Elapsed, oldServiceDataWatch.Elapsed, newServiceDataWatch.Elapsed); singleProfileWatch.Reset(); oldServiceDataWatch.Reset(); newServiceDataWatch.Reset(); } } testingDurationWatch.Stop(); LogManager.Instance.LogSummary(testingDurationWatch.Elapsed, errorType, errorMessage); LogManager.Instance.Dispose(); }
private void UserEducationTrainingInfo_Trainings() { var oldValues = ParsingHelper.ParseStructuredListOfValues( this.OldDataNodes, EnumOldServiceFieldsAsKeys.training.ToString(), new EnumOldServiceFieldsAsKeys[] { EnumOldServiceFieldsAsKeys.departmentName, EnumOldServiceFieldsAsKeys.startYear, EnumOldServiceFieldsAsKeys.endYear, EnumOldServiceFieldsAsKeys.position, EnumOldServiceFieldsAsKeys.locationName }); // TODO: Location belongs in a dedicated test var newValues = new HashSet <Dictionary <EnumOldServiceFieldsAsKeys, string> >(); Dictionary <EnumOldServiceFieldsAsKeys, string> properties; if (this.newDataTraining != null) { foreach (var newValue in this.newDataTraining) { properties = new Dictionary <EnumOldServiceFieldsAsKeys, string>(); try { properties.Add(EnumOldServiceFieldsAsKeys.departmentName, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Department))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.departmentName, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.startYear, newValue.StartDate.ToString()); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.startYear, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.endYear, newValue.EndDate.ToString()); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.endYear, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.position, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Position))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.position, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.locationName, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Institution))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.locationName, string.Empty); } newValues.Add(properties); } } this.CompareAndLog_Test(EnumTestUnitNames.UserEducationTrainingInfo_Trainings, "Comparing Training(s)", oldValues, newValues); }
protected override void RunAllSingleTests() { this.CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_GeneralContact_OfficePhone, "Comparing General Contact", this.OldDataNodes, EnumOldServiceFieldsAsKeys.officePhone.ToString(), ParsingHelper.FormatPhoneNumber((this.newData != null?this.newData.AcademicPhone:string.Empty), (this.newData != null?this.newData.AcademicPhoneExtension:string.Empty))); this.CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_GeneralContact_ClinicPhone, "Comparing General Contact", this.OldDataNodes, EnumOldServiceFieldsAsKeys.clinicPhone.ToString(), ParsingHelper.FormatPhoneNumber((this.newData != null?this.newData.ClinicPhone:string.Empty), (this.newData != null?this.newData.ClinicPhoneExtension:string.Empty))); this.CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_GeneralContact_LabPhone, "Comparing General Contact", this.OldDataNodes, EnumOldServiceFieldsAsKeys.labPhone.ToString(), ParsingHelper.FormatPhoneNumber((this.newData != null?this.newData.LabPhone:string.Empty), (this.newData != null?this.newData.LabPhoneExtension:string.Empty))); this.CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_GeneralContact_OfficeFax, "Comparing General Contact", this.OldDataNodes, EnumOldServiceFieldsAsKeys.officeFax.ToString(), ParsingHelper.FormatPhoneNumber((this.newData != null?this.newData.OfficeFax:string.Empty))); this.CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_GeneralContact_ClinicFax, "Comparing General Contact", this.OldDataNodes, EnumOldServiceFieldsAsKeys.clinicFax.ToString(), ParsingHelper.FormatPhoneNumber((this.newData != null?this.newData.ClinicFax:string.Empty))); this.CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_GeneralContact_MobilePhone, "Comparing General Contact", "False", (this.newData != null ? this.newData.IsMobilePhoneDisplayed.ToString() : string.Empty)); this.CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_GeneralContact_Pager, "Comparing General Contact", "False", (this.newData != null ? this.newData.IsPagerDisplayed.ToString() : string.Empty)); ComputeOverallSeverity(); }
private void UserContactLocationInfo_Addresses_Test() { var watch = new Stopwatch(); watch.Start(); var oldValues = ParsingHelper.ParseStructuredListOfValues(this.OldDataNodes, EnumOldServiceFieldsAsKeys.location.ToString(), new EnumOldServiceFieldsAsKeys[] { EnumOldServiceFieldsAsKeys.locationName, EnumOldServiceFieldsAsKeys.building, EnumOldServiceFieldsAsKeys.addressLine1, EnumOldServiceFieldsAsKeys.suite, EnumOldServiceFieldsAsKeys.city, EnumOldServiceFieldsAsKeys.state, EnumOldServiceFieldsAsKeys.zipCode, EnumOldServiceFieldsAsKeys.type, EnumOldServiceFieldsAsKeys.displayOrder }); // add mailing address manually if (this.OldDataNodes != null) { var mailingAddress = new Dictionary <EnumOldServiceFieldsAsKeys, string>(); try { mailingAddress.Add(EnumOldServiceFieldsAsKeys.locationName, ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.mailingAddressName.ToString())); } catch (Exception) { // make sure a value is present for each index mailingAddress.Add(EnumOldServiceFieldsAsKeys.locationName, string.Empty); } mailingAddress.Add(EnumOldServiceFieldsAsKeys.building, string.Empty); try { StringBuilder value = new StringBuilder(); value.Append(ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.mailingAddress1.ToString())); value.Append(" "); value.Append(ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.mailingAddress2.ToString())); mailingAddress.Add(EnumOldServiceFieldsAsKeys.addressLine1, value.ToString().Trim()); } catch (Exception) { // make sure a value is present for each index mailingAddress.Add(EnumOldServiceFieldsAsKeys.addressLine1, string.Empty); } mailingAddress.Add(EnumOldServiceFieldsAsKeys.suite, string.Empty); try { mailingAddress.Add(EnumOldServiceFieldsAsKeys.city, ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.mailingAddressCity.ToString())); } catch (Exception) { // make sure a value is present for each index mailingAddress.Add(EnumOldServiceFieldsAsKeys.city, string.Empty); } try { mailingAddress.Add(EnumOldServiceFieldsAsKeys.state, ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.mailingAddressState.ToString())); } catch (Exception) { // make sure a value is present for each index mailingAddress.Add(EnumOldServiceFieldsAsKeys.state, string.Empty); } try { mailingAddress.Add(EnumOldServiceFieldsAsKeys.zipCode, ParsingHelper.ParseSingleValue(this.OldDataNodes, EnumOldServiceFieldsAsKeys.mailingAddressZip.ToString())); } catch (Exception) { // make sure a value is present for each index mailingAddress.Add(EnumOldServiceFieldsAsKeys.zipCode, string.Empty); } bool atLeastOneFieldPopulated = mailingAddress.Where(x => !string.IsNullOrWhiteSpace(x.Value)).Count() > 0; if (atLeastOneFieldPopulated) { oldValues.Add(mailingAddress); } } var newValues = new HashSet <Dictionary <EnumOldServiceFieldsAsKeys, string> >(); Dictionary <EnumOldServiceFieldsAsKeys, string> properties; if (this.newDataUserAddress != null) { foreach (var newValue in this.newDataUserAddress) { properties = new Dictionary <EnumOldServiceFieldsAsKeys, string>(); try { properties.Add(EnumOldServiceFieldsAsKeys.locationName, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Address.OfficeName))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.locationName, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.building, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Address.Building.Name))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.building, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.addressLine1, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Address.Building.StreetAddress))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.addressLine1, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.suite, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Address.Suite))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.suite, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.city, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Address.Building.Locality.City))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.city, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.state, newValue.Address.Building.Locality.StateRegionProvince); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.state, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.zipCode, newValue.Address.Building.Locality.PostalCode); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.zipCode, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.type, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Address.AddressType.Name))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.type, string.Empty); } try { // #615 - sort order for locations should be matched in new service properties.Add(EnumOldServiceFieldsAsKeys.displayOrder, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.SortOrder.ToString()))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.displayOrder, string.Empty); } newValues.Add(properties); } } this.CompareAndLog_Test(EnumTestUnitNames.UserContactLocationInfo_Addresses, "Comparing Address(es)", oldValues, newValues, watch); }
private void UserEducationTrainingInfo_BoardCertifications() { var oldValues = ParsingHelper.ParseStructuredListOfValues( this.OldDataNodes, EnumOldServiceFieldsAsKeys.boardCertification.ToString(), new EnumOldServiceFieldsAsKeys[] { EnumOldServiceFieldsAsKeys.specialty, EnumOldServiceFieldsAsKeys.organization, EnumOldServiceFieldsAsKeys.certificationYear}); foreach (var oldValue in oldValues) { if (oldValue[EnumOldServiceFieldsAsKeys.organization] != null && oldValue[EnumOldServiceFieldsAsKeys.organization].ToLower().Trim() == "none") { oldValue[EnumOldServiceFieldsAsKeys.organization] = string.Empty; } } // TODO: Location belongs in a dedicated test var newValues = new HashSet<Dictionary<EnumOldServiceFieldsAsKeys, string>>(); Dictionary<EnumOldServiceFieldsAsKeys, string> properties; if (this.newDataBoardCertification != null) { foreach (var newValue in this.newDataBoardCertification) { properties = new Dictionary<EnumOldServiceFieldsAsKeys, string>(); try { properties.Add(EnumOldServiceFieldsAsKeys.specialty, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.SpecialtyName))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.specialty, string.Empty); } try { if (!newValue.CertificationOrganization.ToLower().Contains("none")) { properties.Add(EnumOldServiceFieldsAsKeys.organization, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.CertificationOrganization))); } else { properties.Add(EnumOldServiceFieldsAsKeys.organization, string.Empty); } } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.organization, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.certificationYear, String.Format("{0:yyyy}", newValue.OriginalDate)); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.certificationYear, string.Empty); } newValues.Add(properties); } } this.CompareAndLog_Test(EnumTestUnitNames.UserPatientCareInfo_BoardCertifications, "Comparing Board Certification(s)", oldValues, newValues); }
/// <summary> /// This is an example where the data is compared as a structure. /// </summary> private void UserEducationTrainingInfo_Services() { var oldValues = ParsingHelper.ParseStructuredListOfValues(this.OldDataNodes, EnumOldServiceFieldsAsKeys.professionalService.ToString(), new EnumOldServiceFieldsAsKeys[] { EnumOldServiceFieldsAsKeys.role, EnumOldServiceFieldsAsKeys.organization, EnumOldServiceFieldsAsKeys.startDate, EnumOldServiceFieldsAsKeys.endDate, EnumOldServiceFieldsAsKeys.category, EnumOldServiceFieldsAsKeys.description }); foreach (var structure in oldValues) { // metadata is added for comparison with more complete new data //structure[EnumOldServiceFieldsAsKeys.role] = "Professional Organization"; try { structure[EnumOldServiceFieldsAsKeys.startDate] = string.Format("{0:yyyy}", DateTime.Parse(structure[EnumOldServiceFieldsAsKeys.startDate], CultureInfo.CurrentCulture)); } catch (Exception) { structure[EnumOldServiceFieldsAsKeys.startDate] = string.Empty; } try { // not dates : present, now, curr, Present, on, psnt, 200, 0201, today, "04/??/19". // YMPS-506 : endDate ongoing <=> null structure[EnumOldServiceFieldsAsKeys.endDate] = string.Format("{0:yyyy}", DateTime.Parse(structure[EnumOldServiceFieldsAsKeys.endDate], CultureInfo.CurrentCulture)); } catch (Exception) { structure[EnumOldServiceFieldsAsKeys.endDate] = string.Empty; } } var newValues = new HashSet <Dictionary <EnumOldServiceFieldsAsKeys, string> >(); Dictionary <EnumOldServiceFieldsAsKeys, string> properties; if (this.newDataService != null) { foreach (var newValue in newDataService) { properties = new Dictionary <EnumOldServiceFieldsAsKeys, string>(); try { properties.Add(EnumOldServiceFieldsAsKeys.role, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Role))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.role, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.organization, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.ServiceOrganization))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.organization, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.startDate, newValue.StartDate.ToString()); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.startDate, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.endDate, newValue.EndDate.ToString()); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.endDate, string.Empty); } try { if (newValue.ServiceCategory.Name == "Unknown") { // keep coherent with old service for testing properties.Add(EnumOldServiceFieldsAsKeys.category, string.Empty); } else { properties.Add(EnumOldServiceFieldsAsKeys.category, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.ServiceCategory.Name))); } } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.category, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.description, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.Description))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.description, string.Empty); } newValues.Add(properties); } } this.CompareAndLog_Test(EnumTestUnitNames.UserHonorServiceInfo_Services, "Comparing Service(s)", oldValues, newValues); }
private void UserEducationTrainingInfo_Honors() { //EnumOldServiceFieldsAsKeys.presentationDate, var oldValues = ParsingHelper.ParseStructuredListOfValues(this.OldDataNodes, EnumOldServiceFieldsAsKeys.professionalHonor.ToString(), new EnumOldServiceFieldsAsKeys[] { EnumOldServiceFieldsAsKeys.award, EnumOldServiceFieldsAsKeys.organization, EnumOldServiceFieldsAsKeys.presentationDate, EnumOldServiceFieldsAsKeys.category }); DatesRegExRewriter rewriter = new DatesRegExRewriter(); List <string> temp = new List <string>(); foreach (var oldValue in oldValues) { temp.Clear(); if (oldValue[EnumOldServiceFieldsAsKeys.presentationDate] != null) { temp.AddRange(rewriter.ConvertDate(HttpUtility.HtmlDecode(oldValue[EnumOldServiceFieldsAsKeys.presentationDate]), true)); oldValue[EnumOldServiceFieldsAsKeys.presentationDate] = String.Join(", ", temp.ToArray());; } } var newValues = new HashSet <Dictionary <EnumOldServiceFieldsAsKeys, string> >(); Dictionary <EnumOldServiceFieldsAsKeys, string> properties; if (this.newDataHonor != null) { foreach (var newValue in this.newDataHonor) { properties = new Dictionary <EnumOldServiceFieldsAsKeys, string>(); try { properties.Add(EnumOldServiceFieldsAsKeys.award, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.AwardName))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.award, string.Empty); } try { properties.Add(EnumOldServiceFieldsAsKeys.organization, HttpUtility.HtmlEncode(HttpUtility.HtmlDecode(newValue.AwardingOrganization))); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.organization, string.Empty); } try { // list of honor dates has been turned into string for comparison - "{0:MM/dd/yy}" properties.Add(EnumOldServiceFieldsAsKeys.presentationDate, String.Join(", ", newValue.HonorDates.Select(ss => string.Format("{0:01/01/yy}", DateTime.Parse(ss.ToString(), CultureInfo.CurrentCulture))).ToArray())); } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.presentationDate, string.Empty); } try { if (newValue.HonorCategory.Name == "Unknown") { // keep coherent with old service for testing properties.Add(EnumOldServiceFieldsAsKeys.category, string.Empty); } else { properties.Add(EnumOldServiceFieldsAsKeys.category, newValue.HonorCategory.Name); } } catch (Exception) { // make sure a value is present for each index properties.Add(EnumOldServiceFieldsAsKeys.category, string.Empty); } newValues.Add(properties); } } this.CompareAndLog_Test(EnumTestUnitNames.UserHonorServiceInfo_Honors, "Comparing Honor(s)", oldValues, newValues); }