public void ExportAsXml_Should_Return_Non_Empty_Stream() { // Arrange _repository.AddNewPage(new Page() { Id = 1 }, "text", "admin", DateTime.UtcNow); _repository.AddNewPage(new Page() { Id = 2 }, "text", "admin", DateTime.UtcNow); // Act Stream stream = _wikiExporter.ExportAsXml(); // Assert Assert.That(stream.Length, Is.GreaterThan(1)); }
public void exportasxml_should_return_non_empty_stream() { // Arrange _pageRepository.AddNewPage(new Page() { Id = 1 }, "text", "admin", DateTime.UtcNow); _pageRepository.AddNewPage(new Page() { Id = 2 }, "text", "admin", DateTime.UtcNow); // Act Stream stream = _wikiExporter.ExportAsXml(); // Assert Assert.That(stream.Length, Is.GreaterThan(1)); }
/// <summary> /// Exports the pages of site including their history as a single XML file. /// </summary> /// <returns>A <see cref="FileStreamResult"/> called 'roadkill-export.xml' containing the XML data. /// If an error occurs, the action adds the error message to the TempData 'ErrorMessage' item.</returns> public ActionResult ExportAsXml() { try { Stream stream = _wikiExporter.ExportAsXml(); FileStreamResult result = new FileStreamResult(stream, "text/xml"); result.FileDownloadName = "roadkill-export.xml"; return(result); } catch (IOException e) { Log.Warn(e, "Unable to export as XML"); TempData["ErrorMessage"] = string.Format(SiteStrings.SiteSettings_Tools_ExportXml_Error, e.Message); return(RedirectToAction("Index")); } }