RhSolutions-AddIn/RhSolutions.Tests/WorkbookValidationTests.cs

39 lines
1.0 KiB
C#
Raw Permalink Normal View History

2023-04-06 21:38:11 +03:00
using RhSolutions.AddIn;
using RhSolutions.Tools;
2023-04-06 21:38:11 +03:00
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-12-09 23:04:49 +03:00
Environment.SetEnvironmentVariable("ISTESTING", "true");
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()
{
Worksheet worksheet = Util.Workbook.Sheets[1];
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];
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
}