This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/examples/CopyFiles/CopyFilesTest.cs

64 lines
1.6 KiB
C#
Raw Normal View History

using System.IO;
using System.Threading.Tasks;
using CliWrap;
using MfGames.IO.Extensions;
2022-09-06 05:53:22 +00:00
using MfGames.Nitride.Tests;
using Xunit;
using Xunit.Abstractions;
namespace CopyFiles;
/// <summary>
/// Tests the execution of the tool and ensures it is working correctly.
/// </summary>
public class CopyFilesTest : NitrideTestBase
{
public CopyFilesTest(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public async Task Run()
{
// Figure out the paths for this test.
DirectoryInfo rootDir =
typeof(CopyFilesProgram).GetDirectory()!.FindGitRoot()!
.GetDirectory("examples/CopyFiles");
2022-07-09 04:52:10 +00:00
DirectoryInfo outputDir = rootDir.GetDirectory("output");
FileInfo projectFile = rootDir.GetFile("CopyFiles.csproj");
this.Logger.Error("A {0}", rootDir);
// Clear out the output directory if we have an old one.
if (outputDir.Exists)
{
outputDir.Delete(true);
}
// Execute the generator. This will throw if there is an exception.
await Cli.Wrap("dotnet")
2022-07-09 04:52:10 +00:00
.WithArguments(
x => x.Add("run")
.Add("--project")
.Add(projectFile.FullName)
.Add("--")
.Add("build"))
.ExecuteAsync();
// Make sure we have our output.
FileInfo aFile = outputDir.GetFile("a.txt");
Assert.True(aFile.Exists);
2022-07-09 04:52:10 +00:00
string aText = aFile.ReadAllText()
.Trim();
Assert.Equal("This is the 'A' file.", aText);
}
}