1 using System;
2 using Mono.Linker.Tests.Extensions;
3 
4 namespace Mono.Linker.Tests.TestCases {
5 	public class TestCase {
TestCase(NPath sourceFile, NPath rootCasesDirectory, NPath originalTestCaseAssemblyPath)6 		public TestCase (NPath sourceFile, NPath rootCasesDirectory, NPath originalTestCaseAssemblyPath)
7 		{
8 			SourceFile = sourceFile;
9 			OriginalTestCaseAssemblyPath = originalTestCaseAssemblyPath;
10 			Name = sourceFile.FileNameWithoutExtension;
11 			DisplayName = $"{sourceFile.RelativeTo (rootCasesDirectory).Parent.ToString (SlashMode.Forward).Replace ('/', '.')}.{sourceFile.FileNameWithoutExtension}";
12 
13 			// A little hacky, but good enough for name.  No reason why namespace & type names
14 			// should not follow the directory structure
15 			ReconstructedFullTypeName = $"{sourceFile.Parent.RelativeTo (rootCasesDirectory.Parent).ToString (SlashMode.Forward).Replace ('/', '.')}.{sourceFile.FileNameWithoutExtension}";
16 		}
17 
18 		public string Name { get; }
19 
20 		public string DisplayName { get; }
21 
22 		public NPath SourceFile { get; }
23 
24 		public NPath OriginalTestCaseAssemblyPath { get; }
25 
26 		public string ReconstructedFullTypeName { get; }
27 
28 		public bool HasLinkXmlFile {
29 			get { return SourceFile.ChangeExtension ("xml").FileExists (); }
30 		}
31 
32 		public NPath LinkXmlFile {
33 			get
34 			{
35 				if (!HasLinkXmlFile)
36 					throw new InvalidOperationException ("This test case does not have a link xml file");
37 
38 				return SourceFile.ChangeExtension ("xml");
39 			}
40 		}
41 	}
42 }