Exemplo n.º 1
0
        public void ExportAsSql_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.ExportAsSql();

            // Assert
            Assert.That(stream.Length, Is.GreaterThan(1));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Exports the roadkill database (User, Page, PageContent) as a SQL script.
        /// </summary>
        /// <returns>A <see cref="FileStreamResult"/> called 'roadkill-export.sql' containing the SQL data.
        /// If an error occurs, the action adds the error message to the TempData 'ErrorMessage' item.</returns>
        public ActionResult ExportAsSql()
        {
            try
            {
                Stream           stream = _wikiExporter.ExportAsSql();
                FileStreamResult result = new FileStreamResult(stream, "text/plain");
                result.FileDownloadName = "roadkill-export.sql";

                return(result);
            }
            catch (IOException e)
            {
                Log.Warn(e, "Unable to export as SQL");
                TempData["ErrorMessage"] = string.Format(SiteStrings.SiteSettings_Tools_ExportXml_Error, e.Message);

                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 3
0
        public void exportassql_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.ExportAsSql();

            // Assert
            Assert.That(stream.Length, Is.GreaterThan(1));
        }