public CheckMappingResult CheckMapping(TestRunImportPluginProfile settings,
                                               IEnumerable <TestCaseTestPlanDTO> testCaseTestPlans,
                                               PluginProfileErrorCollection errors)
        {
            try
            {
                var uri = settings.FrameworkType == FrameworkTypes.FrameworkTypes.JenkinsHudson
                                                ? new Uri(string.Format("{0}/lastCompletedBuild/testReport/api/xml", settings.ResultsFilePath.TrimEnd(new[] { '/', '\\' })))
                                                : new Uri(settings.ResultsFilePath);
                var factoryResult = _streamFactory.OpenStream(uri, settings.PassiveMode);

                if (factoryResult != null)
                {
                    using (factoryResult.Stream)
                    {
                        using (var reader = new StreamReader(factoryResult.Stream))
                        {
                            try
                            {
                                var result = _resultsReaderFactory.GetResolver(settings, reader).GetTestRunImportResults();
                                if (result.Count > 0)
                                {
                                    var resolver = _resolverFactory.GetResolver(settings, result, testCaseTestPlans);
                                    return(resolver.ResolveTestCaseNames(errors));
                                }
                            }
                            catch (ApplicationException)
                            {
                                throw;
                            }
                            catch (XmlException ex)
                            {
                                throw new ApplicationException("Error parsing NUnit results XML file", ex);
                            }
                            catch (Exception ex)
                            {
                                throw new ApplicationException("Error importing NUnit results XML file", ex);
                            }
                        }
                    }
                }
            }
            catch (UriFormatException ex)
            {
                errors.Add(new PluginProfileError
                {
                    FieldName = "ResultsFilePath",
                    Message   = ex.Message
                });
            }
            catch (ApplicationException ex)
            {
                errors.Add(new PluginProfileError
                {
                    FieldName = "ResultsFilePath",
                    Message   = ex.Message
                });
            }
            catch (Exception ex)
            {
                errors.Add(new PluginProfileError
                {
                    FieldName = "ResultsFilePath",
                    Message   = string.Format("Could not read file \"{0}\": {1}", settings.ResultsFilePath, ex.Message)
                });
            }
            return(new CheckMappingResult {
                Errors = errors, NamesMappers = new List <NamesMapper>()
            });
        }