RhSolutions-AddIn/RhSolutions.Tests/WorkbookValidationTests.cs

39 lines
992 B
C#
Raw Normal View History

2023-04-06 21:38:11 +03:00
using RhSolutions.AddIn;
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()
{
Worksheet ws = Util.Workbook.Sheets[1];
ws.Validate();
Assert.True(WorksheetValidator.IsValid());
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 ws = Util.Workbook.Sheets[1];
ws.Validate();
Assert.False(WorksheetValidator.IsValid());
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
}