/// <summary> /// Diffs the request or response headers /// </summary> /// <param name="result"></param> /// <param name="firstText"></param> /// <param name="secondText"></param> /// <param name="firstBasePos">The starting position for the first text relative to the entire request/response text</param> /// <param name="secondBasePos">The starting position for the second text relative to the entire request/response text</param> /// <returns></returns> private RequestsDifferResult DiffHeaders(RequestsDifferResult result, string firstText, string secondText, int firstBasePos, int secondBasePos) { //next diff the headers HeadersDiffCollection firstHeaders = new HeadersDiffCollection(); HeadersDiffCollection secondHeaders = new HeadersDiffCollection(); firstHeaders.BasePosition = firstBasePos; secondHeaders.BasePosition = secondBasePos; firstHeaders.Import(firstText); secondHeaders.Import(secondText); GenericDiffer headersDiffer = new GenericDiffer(); headersDiffer.Properties.Sorted = true; headersDiffer.Properties.CaseInSensitiveSort = true; headersDiffer.AddTask(firstHeaders); headersDiffer.AddTask(secondHeaders); headersDiffer.DoDiff(); //obtain the resulting differences and add them to the result result = AppendDiffs(result, headersDiffer); return(result); }
/// <summary> /// Appends a set of differences from the specified differ to the current differences /// </summary> /// <param name="result"></param> /// <param name="differ"></param> /// <returns></returns> private RequestsDifferResult AppendDiffs(RequestsDifferResult result, GenericDiffer differ) { if (result.DiffsForFirst != null) { result.DiffsForFirst.AddRange(differ.GetResultingDifferences(0)); } else { result.DiffsForFirst = differ.GetResultingDifferences(0); } if (result.DiffsForSecond != null) { result.DiffsForSecond.AddRange(differ.GetResultingDifferences(1)); } else { result.DiffsForSecond = differ.GetResultingDifferences(1); } return(result); }