|
| 1 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
1 | 2 | using ServerCodeExciser; |
2 | 3 | using ServerCodeExcisionCommon; |
3 | | -using Spectre.Console; |
4 | 4 | using System; |
5 | 5 | using System.IO; |
6 | 6 | using UnrealAngelscriptServerCodeExcision; |
7 | 7 |
|
8 | | -public class IntegrationTests |
| 8 | +[TestClass] |
| 9 | +public class ExcisionIntegrationTests |
9 | 10 | { |
10 | | - private static string TestProblemPath = @"Problems"; |
11 | | - private static string TestAnswerPath = @"Answers"; |
| 11 | + private static string DataRootDir = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, "..", "..", "..")); |
12 | 12 |
|
13 | | - public static int Main(string[] args) |
| 13 | + [TestMethod] |
| 14 | + public void ExciseAngelscriptCases() |
14 | 15 | { |
15 | 16 | int numTestFailures = 0; |
16 | 17 | int numTestCases = 0; |
17 | 18 |
|
18 | | - try |
19 | | - { |
20 | | - // Run for Angelscript |
21 | | - var angelscriptResult = RunExciserIntegrationTests( |
22 | | - ".as", |
23 | | - Path.Combine(Environment.CurrentDirectory, TestProblemPath, "Angelscript"), |
24 | | - Path.Combine(Environment.CurrentDirectory, TestAnswerPath, "Angelscript"), |
25 | | - ref numTestFailures, |
26 | | - ref numTestCases); |
27 | | - |
28 | | - // Run for "common" |
29 | | - var commonResult = RunExciserIntegrationTests( |
30 | | - ".common", |
31 | | - Path.Combine(Environment.CurrentDirectory, TestProblemPath, "Common"), |
32 | | - Path.Combine(Environment.CurrentDirectory, TestAnswerPath, "Common"), |
33 | | - ref numTestFailures, |
34 | | - ref numTestCases); |
35 | | - |
36 | | - Console.WriteLine("----------------------------"); |
37 | | - Console.WriteLine($"{numTestCases} test(s) executed."); |
38 | | - Console.WriteLine($"{numTestFailures} test(s) failed."); |
39 | | - } |
40 | | - catch (Exception e) |
41 | | - { |
42 | | - AnsiConsole.WriteException(e); |
43 | | - return 1; |
44 | | - } |
| 19 | + // Run for Angelscript |
| 20 | + var actual = RunExciserIntegrationTests( |
| 21 | + ".as", |
| 22 | + Path.Combine(DataRootDir, "Problems", "Angelscript"), |
| 23 | + Path.Combine(DataRootDir, "Answers", "Angelscript"), |
| 24 | + ref numTestFailures, |
| 25 | + ref numTestCases); |
| 26 | + |
| 27 | + Assert.AreEqual(EExciserReturnValues.Success, actual); |
| 28 | + Assert.AreEqual(0, numTestFailures); |
| 29 | + } |
| 30 | + |
| 31 | + [TestMethod] |
| 32 | + public void ExciseCommonCases() |
| 33 | + { |
| 34 | + int numTestFailures = 0; |
| 35 | + int numTestCases = 0; |
| 36 | + |
| 37 | + // Run for "common" |
| 38 | + var actual = RunExciserIntegrationTests( |
| 39 | + ".common", |
| 40 | + Path.Combine(DataRootDir, "Problems", "Common"), |
| 41 | + Path.Combine(DataRootDir, "Answers", "Common"), |
| 42 | + ref numTestFailures, |
| 43 | + ref numTestCases); |
45 | 44 |
|
46 | | - return numTestFailures == 0 ? 0 : 1; |
| 45 | + Assert.AreEqual(EExciserReturnValues.Success, actual); |
| 46 | + Assert.AreEqual(0, numTestFailures); |
47 | 47 | } |
48 | 48 |
|
49 | 49 | private static EExciserReturnValues RunExciserIntegrationTests(string fileExtension, string inputPath, string outputPath, ref int numTestFailures, ref int numTestCases) |
|
0 commit comments