Skip to content

Commit

Permalink
Merge branch 'release-7.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bovender committed Jul 5, 2016
2 parents e16fa67 + 7c4816e commit 35a59cf
Show file tree
Hide file tree
Showing 70 changed files with 4,185 additions and 2,070 deletions.
14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
SHELL := /bin/bash
.PHONY: credits publish-alpha all
.PHONY: credits publish all

help:
# Target publish-alpha: Pushes the current alpha version to the server using the latest tag
# Also pushes the branch and tags to the remote repository

credits: XLToolbox/html/credits.html
credits: XLToolbox/Resources/html/credits.html

XLToolbox/html/credits.html: ../web/content/about.html.haml
sed -e '1,/<!-- 8< -->/d; /vim:/d; s/^\( \)\{3\}//' ../web/content/about.html.haml | perl -0777 -pe 's/\[([^]]+)\]\([^)]+\)/\1/msg' | pandoc -H XLToolbox/html/style.html > XLToolbox/html/credits.html
XLToolbox/Resources/html/credits.html: ../web/content/about.haml
sed -e '1,/<!-- 8< -->/d; /vim:/d; s/^\( \)\{4\}//' ../web/content/about.haml | perl -0777 -pe 's/\[([^]]+)\]\([^)]+\)/\1/msg' | pandoc -H XLToolbox/Resources/html/style.html > XLToolbox/Resources/html/credits.html

GITTAG=$(shell git describe master)
VERSION=$(GITTAG:v%=%)
publish-beta:
scp publish/release/XLToolbox-$(VERSION).exe [email protected]:/home/frs/project/xltoolbox/beta/
publish:
git push
git push --tags
publish/create-release.rb
42 changes: 19 additions & 23 deletions Tests/Csv/CsvFileTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,13 @@ public void ExportSimpleCsv()
// For testing we 'hide' a pipe symbol in the field.
ws.Cells[4, 5] = "wor|d";
ws.Cells[4, 6] = 88.5;
CsvFile csv = new CsvFile();
CsvExporter model = new CsvExporter();
string fn = System.IO.Path.GetTempFileName();
csv.FileName = fn;
csv.FieldSeparator = "|";
model.FileName = fn;
model.FieldSeparator = "|";
// Use a funky decimal separator
csv.DecimalSeparator = "~";
csv.Export();
Task t = new Task(() =>
{
while (csv.IsProcessing) { }
});
t.Start();
t.Wait(5000);
Assert.IsFalse(csv.IsProcessing, "Exporter is still processing!");
model.DecimalSeparator = "~";
model.Execute();
string contents = System.IO.File.ReadAllText(fn);
string expected = String.Format(
"hello|13{0}\"wor|d\"|88~5{0}",
Expand All @@ -67,24 +60,25 @@ public void ExportLargeCsv()
Worksheet ws = Instance.Default.ActiveWorkbook.Worksheets.Add();
ws.Cells[1, 1] = "hello";
ws.Cells[1000, 16384]= "world";
CsvFile csv = new CsvFile();
CsvExporter model = new CsvExporter();
CsvExportViewModel vm = new CsvExportViewModel(model);
string fn = System.IO.Path.GetTempFileName();
csv.FileName = fn;
vm.FileName = fn;
bool progressCompletedRaised = false;
csv.ProcessSucceeded += (sender, args) =>
vm.ProcessFinishedMessage.Sent += (sender, args) =>
{
progressCompletedRaised = true;
};
csv.Export();
vm.StartProcess();
Task t = new Task(() =>
{
while (csv.IsProcessing) { }
while (model.IsProcessing) { }
});
t.Start();
t.Wait(15000);
if (csv.IsProcessing)
if (vm.IsProcessing)
{
csv.CancelExport();
vm.CancelProcess();
Assert.Inconclusive("CSV export took too long, did not finish.");
// Do not delete the file, leave it for inspection
}
Expand All @@ -105,12 +99,13 @@ public void CsvExportPerformance()
Worksheet ws = Instance.Default.ActiveWorkbook.Worksheets.Add();
ws.Cells[1, 1] = "hello";
ws.Cells[200, 5] = "world";
CsvFile csv = new CsvFile();
CsvExporter model = new CsvExporter();
CsvExportViewModel vm = new CsvExportViewModel(model);
string fn = System.IO.Path.GetTempFileName();
csv.FileName = fn;
model.FileName = fn;
bool running = true;
long start = 0;
csv.ProcessSucceeded += (sender, args) =>
vm.ProcessFinishedMessage.Sent += (sender, args) =>
{
Console.WriteLine(method + ": *** Export completed ***");
long stop = DateTime.Now.Ticks;
Expand All @@ -130,7 +125,8 @@ public void CsvExportPerformance()
);
waitTask.Start();
start = DateTime.Now.Ticks;
csv.Export(ws.UsedRange);
model.Range = ws.UsedRange;
vm.StartProcess();
waitTask.Wait(-1);
}

Expand Down
55 changes: 35 additions & 20 deletions Tests/Excel/WorkbookViewModelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@

namespace XLToolbox.Test.Excel
{

/// <summary>
/// Unit tests for the XLToolbox.Core.Excel namespace.
/// </summary>
[TestFixture]
class WorkbookViewModelTest
{
[TestFixtureTearDown]
public void TearDown()
{
Instance.Default.Dispose();
}

[Test]
public void WorkbookViewModelProperties()
{
Expand Down Expand Up @@ -60,6 +67,7 @@ public void MoveSheetsUp()

// With no sheets selected, the move-up command should
// be disabled.
wvm.Sheets.First(sheet => sheet.IsSelected).IsSelected = false;
Assert.IsFalse(wvm.MoveSheetUp.CanExecute(null),
"Move command is enabled, should be disabled with no sheets selected.");

Expand Down Expand Up @@ -91,6 +99,7 @@ public void MoveSheetsDown()

// With no sheets selected, the move-down command should
// be disabled.
wvm.Sheets.First(sheet => sheet.IsSelected).IsSelected = false;
Assert.IsFalse(wvm.MoveSheetDown.CanExecute(null),
"Move-down command is enabled, should be disabled with no sheets selected.");

Expand Down Expand Up @@ -122,10 +131,12 @@ public void MoveFirstSheetDown()

// With no sheets selected, the move-down command should
// be disabled.
wb.Sheets[wb.Sheets.Count].Activate();
wvm.Sheets.First(sheet => sheet.IsSelected).IsSelected = false;
Assert.IsFalse(wvm.MoveSheetDown.CanExecute(null),
"Move-down command is enabled, should be disabled with no sheets selected.");

svm.IsSelected = true;
wb.Sheets[1].Activate();
Assert.IsTrue(wvm.MoveSheetDown.CanExecute(null),
"Move-down command is disabled, should be enabled with one sheet selected.");

Expand All @@ -140,15 +151,16 @@ public void MoveSheetsToTop()
{
Workbook wb = Instance.Default.CreateWorkbook(8);
WorkbookViewModel wvm = new WorkbookViewModel(wb);
wvm.Sheets.First(sheet => sheet.IsSelected).IsSelected = false;

// Without sheets selected, the Move-to-top command should be disabled
Assert.IsFalse(wvm.MoveSheetsToTop.CanExecute(null),
"The Move-to-top command should be disabled without selected sheets.");

// Select the fourth and sixth sheets and remember their names
SheetViewModel svm4 = wvm.Sheets[3];
svm4.IsSelected = true;
string sheetName4 = svm4.DisplayString;
// // Select the fourth and sixth sheets and remember their names
// SheetViewModel svm4 = wvm.Sheets[3];
// svm4.IsSelected = true;
// string sheetName4 = svm4.DisplayString;

SheetViewModel svm6 = wvm.Sheets[5];
svm6.IsSelected = true;
Expand All @@ -168,9 +180,9 @@ public void MoveSheetsToTop()
// Verify that the display strings of the view models correspond to
// the names of the worksheets in the workbook, to make sure that
// the worksheets have indeed been rearranged as well.
Assert.AreEqual(sheetName4, wb.Sheets[1].Name,
"Moving the sheets to top was not performed on the actual workbook");
Assert.AreEqual(sheetName6, wb.Sheets[2].Name,
// Assert.AreEqual(sheetName4, wb.Sheets[1].Name,
// "Moving the sheets to top was not performed on the actual workbook");
Assert.AreEqual(sheetName6, wb.Sheets[1].Name,
"Moving the sheets to top was not performed for all sheets on the actual workbook");
}

Expand All @@ -181,13 +193,14 @@ public void MoveSheetsToBottom()
WorkbookViewModel wvm = new WorkbookViewModel(wb);

// Without sheets selected, the Move-to-bottom command should be disabled
wvm.Sheets.First(sheet => sheet.IsSelected).IsSelected = false;
Assert.IsFalse(wvm.MoveSheetsToBottom.CanExecute(null),
"The Move-to-bottom command should be disabled without selected sheets.");

// Select the fourth and sixth sheets and remember their names
SheetViewModel svm2 = wvm.Sheets[1];
svm2.IsSelected = true;
string sheetName2 = svm2.DisplayString;
// SheetViewModel svm2 = wvm.Sheets[1];
// svm2.IsSelected = true;
// string sheetName2 = svm2.DisplayString;

SheetViewModel svm4 = wvm.Sheets[3];
svm4.IsSelected = true;
Expand All @@ -207,8 +220,8 @@ public void MoveSheetsToBottom()
// Verify that the display strings of the view models correspond to
// the names of the worksheets in the workbook, to make sure that
// the worksheets have indeed been rearranged as well.
Assert.AreEqual(sheetName2, wb.Sheets[wb.Sheets.Count-1].Name,
"Moving the sheets to bottom was not performed on the actual workbook");
// Assert.AreEqual(sheetName2, wb.Sheets[wb.Sheets.Count-1].Name,
// "Moving the sheets to bottom was not performed on the actual workbook");
Assert.AreEqual(sheetName4, wb.Sheets[wb.Sheets.Count].Name,
"Moving the sheets to bottom was not performed for all sheets on the actual workbook");
}
Expand All @@ -219,10 +232,11 @@ public void DeleteSheets()
Workbook wb = Instance.Default.CreateWorkbook(8);
int oldCount = wb.Sheets.Count;
WorkbookViewModel wvm = new WorkbookViewModel(wb);
wvm.Sheets.First(sheet => sheet.IsSelected).IsSelected = false;
Assert.IsFalse(wvm.DeleteSheets.CanExecute(null),
"Delete sheets command should be disabled with no sheets selected.");
wvm.Sheets[2].IsSelected = true;
wvm.Sheets[4].IsSelected = true;
// wvm.Sheets[4].IsSelected = true;
string sheetName3 = wvm.Sheets[2].DisplayString;
string sheetName5 = wvm.Sheets[4].DisplayString;
int numSelected = wvm.NumSelectedSheets;
Expand Down Expand Up @@ -256,12 +270,12 @@ public void DeleteSheets()
},
String.Format("Sheet {0} (sheetName3) should have been deleted but is still there.", sheetName3)
);
Assert.Throws(typeof(System.Runtime.InteropServices.COMException), () =>
{
obj = wb.Sheets[sheetName5];
},
String.Format("Sheet {0} (sheetName5) should have been deleted but is still there.", sheetName5)
);
// Assert.Throws(typeof(System.Runtime.InteropServices.COMException), () =>
// {
// obj = wb.Sheets[sheetName5];
// },
// String.Format("Sheet {0} (sheetName5) should have been deleted but is still there.", sheetName5)
// );
}

[Test]
Expand All @@ -283,6 +297,7 @@ public void RenameSheet()
string oldName = wvm.Sheets[0].DisplayString;
string newName = "valid new name";
bool messageSent = false;
wvm.Sheets.First(sheet => sheet.IsSelected).IsSelected = false;
Assert.False(wvm.RenameSheet.CanExecute(null),
"Rename sheet command should be disabled with no sheet selected.");
wvm.Sheets[0].IsSelected = true;
Expand Down
49 changes: 28 additions & 21 deletions Tests/Export/ExporterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,36 @@
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.IO;
using NUnit.Framework;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Office.Interop.Excel;
using XLToolbox.Export;
using XLToolbox.Excel.ViewModels;
using NUnit.Framework;
using Bovender.Unmanaged;
using XLToolbox.Excel.ViewModels;
using XLToolbox.Export;
using XLToolbox.Export.Models;
using System.Threading.Tasks;
using XLToolbox.Export.ViewModels;

namespace XLToolbox.Test.Export
{
[TestFixture]
class ExporterTest
{
[SetUp]
[TestFixtureSetUp]
public void SetUp()
{
// Force starting Excel
Instance i = Instance.Default;
SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
}

[TestFixtureTearDown]
public void TearDown()
{
Instance.Default.Dispose();
}

[Test]
Expand Down Expand Up @@ -68,8 +77,8 @@ public void ExportChartObject(FileType fileType, int dpi, ColorSpace colorSpace)
settings.Width = 160;
settings.Height = 40;
File.Delete(settings.FileName);
Exporter exporter = new Exporter();
exporter.ExportSelection(settings);
Exporter exporter = new Exporter(settings);
exporter.Execute();
Assert.IsTrue(File.Exists(settings.FileName));
}

Expand All @@ -85,13 +94,12 @@ public void ExportChartSheet()
settings.FileName = Path.GetFileNameWithoutExtension(Path.GetTempFileName())
+ preset.FileType.ToFileNameExtension();
File.Delete(settings.FileName);
Exporter exporter = new Exporter();
exporter.ExportSelectionQuick(settings);
Exporter exporter = new Exporter(settings, true);
exporter.Execute();
Assert.IsTrue(File.Exists(settings.FileName), "Output file was not created.");
}

[Test]
[RequiresSTA]
[TestCase(BatchExportScope.ActiveSheet, BatchExportObjects.Charts, BatchExportLayout.SingleItems, 1)]
[TestCase(BatchExportScope.ActiveWorkbook, BatchExportObjects.Charts, BatchExportLayout.SingleItems, 7)]
[TestCase(BatchExportScope.ActiveWorkbook, BatchExportObjects.Charts, BatchExportLayout.SheetLayout, 4)]
Expand Down Expand Up @@ -120,17 +128,16 @@ public void BatchExport(
settings.Layout = layout;
settings.Objects = objects;
settings.Scope = scope;
Exporter exporter = new Exporter();
BatchExporter exporter = new BatchExporter(settings);
BatchExportSettingsViewModel vm = new BatchExportSettingsViewModel(exporter);
bool finished = false;
exporter.ProcessSucceeded += (sender, args) => { finished = true; };
exporter.ExportBatchAsync(settings);
Task checkFinishedTask = new Task(() =>
{
while (finished == false) ;
});
checkFinishedTask.Start();
checkFinishedTask.Wait(10000);
Assert.IsTrue(finished, "Export progress did not finish, timeout reached.");
bool abort = false;
vm.ProcessFinishedMessage.Sent += (sender, args) => { finished = true; };
vm.StartProcess();
Timer t = new Timer((obj) => abort = true, null, 8000, Timeout.Infinite);
while (!finished && !abort) ;
t.Dispose();
Assert.IsFalse(abort, "Export progress did not finish, timeout reached.");
Assert.AreEqual(expectedNumberOfFiles,
Directory.GetFiles(settings.Path).Length);
Directory.Delete(settings.Path, true);
Expand Down
4 changes: 2 additions & 2 deletions Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.0.26")]
[assembly: AssemblyFileVersion("7.0.0.26")]
[assembly: AssemblyVersion("7.0.0.27")]
[assembly: AssemblyFileVersion("7.0.0.27")]
8 changes: 4 additions & 4 deletions Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
</ProjectReference>
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug %28Bovender via NuGet%29'">
<Reference Include="Bovender, Version=0.10.0.0, Culture=neutral, PublicKeyToken=df1c15557d8b6df8, processorArchitecture=MSIL">
<Reference Include="Bovender, Version=0.11.0.0, Culture=neutral, PublicKeyToken=df1c15557d8b6df8, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Bovender.0.10.0.0\lib\net40\Bovender.dll</HintPath>
<HintPath>..\packages\Bovender.0.11.0.0\lib\net40\Bovender.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Release'">
<Reference Include="Bovender, Version=0.10.0.0, Culture=neutral, PublicKeyToken=df1c15557d8b6df8, processorArchitecture=MSIL">
<Reference Include="Bovender, Version=0.11.0.0, Culture=neutral, PublicKeyToken=df1c15557d8b6df8, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Bovender.0.10.0.0\lib\net40\Bovender.dll</HintPath>
<HintPath>..\packages\Bovender.0.11.0.0\lib\net40\Bovender.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Tests/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
limitations under the License.
-->
<packages>
<package id="Bovender" version="0.10.0.0" targetFramework="net40" />
<package id="Bovender" version="0.11.0.0" targetFramework="net40" />
<package id="Expression.Blend.Sdk" version="1.0.2" targetFramework="net40" />
<package id="NLog" version="4.3.3" targetFramework="net40" />
<package id="NUnitTestAdapter" version="2.0.0" targetFramework="net40" />
Expand Down
Loading

0 comments on commit 35a59cf

Please sign in to comment.