Пример #1
0
        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);
        }
Пример #2
0
 /// <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);
 }
Пример #3
0
 /// <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);
 }
Пример #4
0
 /// <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);
 }
Пример #5
0
 /// <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);
Пример #6
0
 /// <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);
 }
Пример #7
0
 /// <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);
 }
Пример #8
0
 /// <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);
 }
Пример #9
0
 /// <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);
 }
Пример #10
0
 /// <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);
 }
Пример #11
0
 /// <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);