RhSolutions-AddIn/RhSolutions.Tests/WorkbookValidationTests.cs

38 lines
979 B
C#
Raw Permalink Normal View History

2023-04-06 21:38:11 +03:00
using RhSolutions.AddIn;
using RhSolutions.Tools;
namespace RhSolutions.Tests;
2023-03-24 06:22:40 +03:00
[ExcelTestSettings(OutOfProcess = true)]
2023-03-31 15:27:31 +03:00
public class WorkbookValidationTests : IDisposable
2023-03-23 07:18:11 +03:00
{
2023-04-06 21:38:11 +03:00
private readonly RhSolutionsAddIn _addIn;
2023-03-31 15:27:31 +03:00
public WorkbookValidationTests()
2023-03-23 07:18:11 +03:00
{
2023-04-06 21:38:11 +03:00
_addIn = new RhSolutionsAddIn();
_addIn.AutoOpen();
2023-03-24 06:22:40 +03:00
Util.Application.Workbooks.Add();
}
2023-03-23 07:18:11 +03:00
2023-05-21 10:24:02 +03:00
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\EmptyTestTable.xlsx")]
2023-03-24 06:22:40 +03:00
public void WorksheetIsCorrect()
{
2023-03-31 15:27:31 +03:00
Worksheet worksheet = Util.Workbook.Sheets[1];
2023-04-06 21:38:11 +03:00
Assert.True(worksheet.IsValidSource());
2023-03-24 06:22:40 +03:00
}
2023-03-23 07:18:11 +03:00
2023-05-21 10:24:02 +03:00
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\EmptyWorkbook.xlsx")]
2023-03-24 06:22:40 +03:00
public void EmptyWorkbookIsNotCorrect()
{
Worksheet worksheet = Util.Workbook.Sheets[1];
2023-04-06 21:38:11 +03:00
Assert.False(worksheet.IsValidSource());
2023-03-24 06:22:40 +03:00
}
2023-03-23 07:18:11 +03:00
2023-03-24 06:22:40 +03:00
public void Dispose()
{
2023-04-06 21:38:11 +03:00
_addIn.AutoClose();
2023-03-31 15:27:31 +03:00
Util.Application.ActiveWindow.Close(SaveChanges: false);
2023-03-23 07:18:11 +03:00
}
2023-04-06 21:38:11 +03:00
}