-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolutionDirectoryFixture.cs
More file actions
42 lines (37 loc) · 1.54 KB
/
SolutionDirectoryFixture.cs
File metadata and controls
42 lines (37 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
namespace Neolution.DotNet.Console.IntegrationTests
{
using System.IO;
/// <summary>
/// Provides the solution directory and Demo project path for integration tests.
/// </summary>
public class SolutionDirectoryFixture
{
/// <summary>
/// Initializes a new instance of the <see cref="SolutionDirectoryFixture"/> class.
/// </summary>
public SolutionDirectoryFixture()
{
var dir = Directory.GetCurrentDirectory();
while (dir != null && !File.Exists(Path.Combine(dir, "Neolution.DotNet.Console.sln")))
{
dir = Path.GetDirectoryName(dir);
}
// Set the solution directory to the one containing the solution file
this.SolutionDirectory = dir ?? throw new DirectoryNotFoundException("Could not find solution directory.");
// Set the Demo project path relative to the solution directory
this.DemoProjectPath = Path.Combine(this.SolutionDirectory, "Neolution.DotNet.Console.Demo", "Neolution.DotNet.Console.Demo.csproj");
if (!File.Exists(this.DemoProjectPath))
{
throw new FileNotFoundException($"Demo project file not found: {this.DemoProjectPath}");
}
}
/// <summary>
/// Gets the solution directory path.
/// </summary>
public string SolutionDirectory { get; }
/// <summary>
/// Gets the Demo project file path.
/// </summary>
public string DemoProjectPath { get; }
}
}