Consider a method which returns an ExcelWorksheet
from an ExcelPackage
(with the Epplus library):
public ExcelWorksheet findExcelSheet(ExcelPackage spreadsheet, string v)
This method throws an Exception
if a worksheet is not found within the spreadsheet whose name is "v".
A unit test is written for this method:
[TestMethod]
public void findExcelSheet_Test()
{
// arrange
ExcelPackage testSpreadsheet = new ExcelPackage();
ExcelWorksheet testWsFPS = testSpreadsheet.Workbook.Worksheets.Add("FPS");
ExcelWorksheet testWsDRS = testSpreadsheet.Workbook.Worksheets.Add("DRS");
ExcelWorksheet testWsDPC = testSpreadsheet.Workbook.Worksheets.Add("DPC");
// act
findExcelSheet(testSpreadsheet, Path.GetRandomFileName()); //or some other random string
// assert
}
How, with Microsoft.VisualStudio.TestTools.UnitTesting
, can it be tested for when it throws the exceptions, and that they are the correct type of exception?