Skip to content

Commit 080be00

Browse files
committed
Added test, that excel saved a file
1 parent d0606c4 commit 080be00

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

GithubActionsHelloWorld/Program.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ public static async Task Main(string[] args)
1313
CreateExcelDocument();
1414
}
1515

16-
private static void CreateExcelDocument()
16+
public static string CreateExcelDocument()
1717
{
18-
Microsoft.Office.Interop.Excel.Application excelApplication = null;
18+
Application excelApplication = null;
1919

2020
try
2121
{
2222
excelApplication = new
23-
Microsoft.Office.Interop.Excel.Application();
23+
Application();
2424
Workbook excelWorkBook = excelApplication.Workbooks.Add();
2525
Worksheet worksheet = (Worksheet)excelWorkBook.Worksheets[1];
2626
worksheet.Cells[1, 1] = "Product Id";
@@ -32,10 +32,12 @@ private static void CreateExcelDocument()
3232
var path = Path.GetTempFileName() + ".xlsx";
3333
Console.WriteLine(path);
3434
excelWorkBook.SaveAs(Path.Combine(path));
35+
return path;
3536
}
3637
catch (Exception ex)
3738
{
3839
Console.WriteLine(ex.Message);
40+
return ex.Message;
3941
}
4042
finally
4143
{
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
using GithubActionsHelloWorld;
2-
using System.Threading.Tasks;
32
using Xunit;
43

54
namespace GithubActionsHelloWorldTests
65
{
76
public class GithubActionsHelloWorldTest
87
{
98
[Fact]
10-
public async Task Main_ShouldRunWithoutError()
9+
public void Main_ShouldRunWithoutError()
1110
{
1211
var args = new string[] { "WrongParameterCount" };
13-
await Program.Main(args);
12+
var path = Program.CreateExcelDocument();
13+
14+
Assert.True(System.IO.File.Exists(path));
1415
}
1516
}
1617
}

0 commit comments

Comments
 (0)