public async Task XmlImporterTest() { XmlImporter importer = new XmlImporter(); ProgressReporter reporter = new ProgressReporter(100); int reportCount = 0; reporter.ProgressChanged += (s, e) => reportCount++; XDocument result = (XDocument)(await importer.ImportAsync(new MemoryStream(Encoding.ASCII.GetBytes(SimpleXml)), reporter)); if (reporter.ErrorMessage != null) Assert.Fail("There was an error message:\n{0}", reporter.ErrorMessage); Assert.IsTrue(reporter.CompletedWithoutError, "Completed with errors"); Assert.NotNull(result, "The result was null"); XElement element = result.Descendants("heading").FirstOrDefault(); Assert.AreEqual("Reminder", element.Value, "Could not decode value"); Assert.AreEqual(1, reportCount, "XmlImporter did not report progress."); Assert.AreEqual(100, reporter.Progress); }
/// <summary> /// Sets the progress. /// </summary> /// <param name="reporter">Reporter.</param> /// <param name="progress">Progress.</param> protected void SetProgress(ProgressReporter reporter, double progress) { reporter?.SetProgress(progress); }
/// <summary> /// Sets if ImportAsync completed without error. /// </summary> /// <param name="reporter">Reporter.</param> /// <param name="value">If set to <c>true</c> value.</param> protected void SetCompletedWithoutError(ProgressReporter reporter, bool value) { reporter?.SetCompletedWithoutError(value); }
/// <summary> /// Sets the error message. /// </summary> /// <param name="reporter">Reporter.</param> /// <param name="message">Message.</param> protected void SetErrorMessage(ProgressReporter reporter, string message) { reporter?.SetErrorMessage(message); }
/// <summary> /// Run the import operations. /// </summary> /// <returns>The async.</returns> /// <param name="stream">Stream.</param> /// <param name="reporter">Reporter.</param> public abstract Task <object> ImportAsync(Stream stream, ProgressReporter reporter = null);
/// <summary> /// Sets the progress label. /// </summary> /// <param name="reporter">Reporter.</param> /// <param name="label">The label.</param> protected void SetProgressLabel(ProgressReporter reporter, string label) { reporter?.SetLabel(label); }
/// <summary> /// Sets the progress. /// </summary> /// <param name="reporter">Reporter.</param> /// <param name="progress">Progress.</param> protected void SetProgress(ProgressReporter reporter, double progress) { reporter?.SetProgress(progress); }
/// <summary> /// Sets the error message. /// </summary> /// <param name="reporter">Reporter.</param> /// <param name="message">Message.</param> protected void SetErrorMessage(ProgressReporter reporter, string message) { reporter?.SetErrorMessage(message); }
/// <summary> /// Sets if ImportAsync completed without error. /// </summary> /// <param name="reporter">Reporter.</param> /// <param name="value">If set to <c>true</c> value.</param> protected void SetCompletedWithoutError(ProgressReporter reporter, bool value) { reporter?.SetCompletedWithoutError(value); }
/// <summary> /// Sets the progress label. /// </summary> /// <param name="reporter">Reporter.</param> /// <param name="label">The label.</param> protected void SetProgressLabel(ProgressReporter reporter, string label) { reporter?.SetLabel(label); }
/// <summary> /// Run the import operations. /// </summary> /// <returns>The async.</returns> /// <param name="stream">Stream.</param> /// <param name="reporter">Reporter.</param> public abstract Task<object> ImportAsync(Stream stream, ProgressReporter reporter = null);