-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
261 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using Xunit; | ||
|
||
namespace SoG_SGreader.Test | ||
{ | ||
public class IntegrationTests | ||
{ | ||
private static string GetExePath() | ||
{ | ||
string projectDirectory = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.Parent.FullName; | ||
|
||
// Exception for GitHub Actions Test Runner | ||
if (Environment.GetEnvironmentVariable("GITHUB_WORKSPACE") != null) { | ||
projectDirectory = Environment.GetEnvironmentVariable("GITHUB_WORKSPACE"); | ||
} | ||
|
||
return Path.Combine(projectDirectory, "SoG_SGreader", "bin", "Debug", "SoG_SGreader.exe"); | ||
} | ||
|
||
private static string GetSaveGamePath(string saveGameNumber) | ||
{ | ||
string projectDirectory = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.Parent.FullName; | ||
|
||
// Exception for GitHub Actions Test Runner | ||
if (Environment.GetEnvironmentVariable("GITHUB_WORKSPACE") != null) { | ||
projectDirectory = Environment.GetEnvironmentVariable("GITHUB_WORKSPACE"); | ||
} | ||
|
||
return Path.Combine(projectDirectory, "SoG_SGreader.Test", "SaveGames", saveGameNumber + ".cha"); | ||
} | ||
|
||
|
||
[Fact] | ||
public void TestSavegameTextOutput() | ||
{ | ||
string arguments = "-t " + GetSaveGamePath("1"); | ||
|
||
// Start the process | ||
using var process = new Process | ||
{ | ||
StartInfo = new ProcessStartInfo | ||
{ | ||
FileName = GetExePath(), | ||
Arguments = arguments, | ||
RedirectStandardOutput = true, | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
} | ||
}; | ||
|
||
process.Start(); | ||
string output = process.StandardOutput.ReadToEnd(); | ||
process.WaitForExit(); | ||
|
||
Assert.Contains("Filesize: 4494", output); | ||
Assert.Contains("Birthday: 24.6.1081", output); | ||
Assert.Contains("ItemsMetCount: 124", output); | ||
Assert.Contains("KilledEnemiesCount: 58", output); | ||
} | ||
|
||
[Fact] | ||
public void TestSavegameJsonOutput() | ||
{ | ||
string arguments = "-j " + GetSaveGamePath("1"); | ||
|
||
// Start the process | ||
using var process = new Process | ||
{ | ||
StartInfo = new ProcessStartInfo | ||
{ | ||
FileName = GetExePath(), | ||
Arguments = arguments, | ||
RedirectStandardOutput = true, | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
} | ||
}; | ||
|
||
process.Start(); | ||
string output = process.StandardOutput.ReadToEnd(); | ||
process.WaitForExit(); | ||
|
||
Assert.Contains("\"MagicByte\": 116", output); | ||
Assert.Contains("\"PlayTimeTotal\": 1645950", output); | ||
Assert.Contains("\"UniquePlayerId\": 451873", output); | ||
Assert.Contains("\"Cash\": 6873538", output); | ||
} | ||
|
||
[Fact] | ||
public void TestPatchOutput() | ||
{ | ||
string arguments = "--patch"; | ||
|
||
// Start the process | ||
using var process = new Process | ||
{ | ||
StartInfo = new ProcessStartInfo | ||
{ | ||
FileName = GetExePath(), | ||
Arguments = arguments, | ||
RedirectStandardOutput = true, | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
} | ||
}; | ||
|
||
process.Start(); | ||
string output = process.StandardOutput.ReadToEnd(); | ||
process.WaitForExit(); | ||
|
||
Assert.Contains(FrmMain.CurrentPatch, output); | ||
} | ||
|
||
[Fact] | ||
public void TestHelpOutput() | ||
{ | ||
string arguments = "--help"; | ||
|
||
// Start the process | ||
using var process = new Process | ||
{ | ||
StartInfo = new ProcessStartInfo | ||
{ | ||
FileName = GetExePath(), | ||
Arguments = arguments, | ||
RedirectStandardOutput = true, | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
} | ||
}; | ||
|
||
process.Start(); | ||
string output = process.StandardOutput.ReadToEnd(); | ||
process.WaitForExit(); | ||
|
||
Assert.Contains("--help", output); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.