| @@ -3700,8 +3700,20 @@ namespace Novacode | |||
| { | |||
| using (FileStream fs = new FileStream(filename, FileMode.Create)) | |||
| { | |||
| CopyStream(memoryStream, fs); | |||
| } | |||
| // Original code | |||
| // fs.Write( memoryStream.ToArray(), 0, (int)memoryStream.Length ); | |||
| // was replaced by save using small buffer | |||
| // CopyStream( memoryStream, fs); | |||
| // Corection is to make position equal to 0 | |||
| if(memoryStream.CanSeek) | |||
| { | |||
| // Write to the beginning of the stream | |||
| memoryStream.Position = 0; | |||
| CopyStream(memoryStream, fs); | |||
| } | |||
| else | |||
| fs.Write(memoryStream.ToArray(), 0, (int)memoryStream.Length); | |||
| } | |||
| } | |||
| else | |||
| { | |||
| @@ -0,0 +1,5 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <packages> | |||
| <package id="NUnit" version="3.6.0" targetFramework="net40" /> | |||
| <package id="NUnitTestAdapter" version="2.0.0" targetFramework="net40" /> | |||
| </packages> | |||
| @@ -76,7 +76,29 @@ namespace UnitTests | |||
| } | |||
| } | |||
| [Test] | |||
| [Test] | |||
| public void Test_DocX_SaveAs() | |||
| { | |||
| string temporaryFilePath = Path.Combine( _directoryDocuments, "temp.docx" ); | |||
| // Load the document 'Paragraphs.docx' | |||
| using( DocX document = DocX.Load( Path.Combine( _directoryWithFiles, "Paragraphs.docx" ) ) ) | |||
| { | |||
| document.InsertParagraph( "text" ); | |||
| // Test the saving of the document. | |||
| document.SaveAs( temporaryFilePath ); | |||
| // Check file size | |||
| FileInfo f = new FileInfo( temporaryFilePath ); | |||
| Assert.IsTrue( f.Length == 9659 ); | |||
| } | |||
| // Delete the tempory file. | |||
| File.Delete( temporaryFilePath ); | |||
| } | |||
| [Test] | |||
| public void TableWithSpecifiedWidths() | |||
| { | |||
| using (var output = File.Open(Path.Combine(_directoryWithFiles, "TableSpecifiedWidths.docx"), FileMode.Create)) | |||
| @@ -46,8 +46,8 @@ | |||
| </AssemblyOriginatorKeyFile> | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> | |||
| <HintPath>..\packages\nunit.framework.2.63.0\lib\nunit.framework.dll</HintPath> | |||
| <Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL"> | |||
| <HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath> | |||
| <Private>True</Private> | |||
| </Reference> | |||
| <Reference Include="System" /> | |||
| @@ -1,6 +1,6 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <packages> | |||
| <package id="NUnit" version="3.4.1" targetFramework="net40" /> | |||
| <package id="NUnit" version="3.6.0" targetFramework="net40" /> | |||
| <package id="NUnit.Console" version="3.4.1" targetFramework="net40" /> | |||
| <package id="NUnit.ConsoleRunner" version="3.4.1" targetFramework="net40" /> | |||
| <package id="NUnit.Extension.NUnitProjectLoader" version="3.4.1" targetFramework="net40" /> | |||