public RootPathConfiguration(string rootPath, RootPathConfigurationType configurationType, string context) { this.RootPath = rootPath; this.ConfigurationType = configurationType; this.Context = context; }
public void RhetoRootAppPathFromDocument(string documentRelativePath, string expectedRootAppPath, RootPathConfigurationType expectedConfigurationType) { var uri = new Uri(Path.Combine(Environment.CurrentDirectory, documentRelativePath)); Console.WriteLine($"Opening file '{uri.LocalPath}.'"); var text = File.ReadAllText(uri.LocalPath); Console.WriteLine($"File contents:\n{text}\n*****************\n"); var rhetosAppContext = serviceProvider.GetRequiredService <RhetosAppContext>(); var documentFactory = serviceProvider.GetRequiredService <RhetosDocumentFactory>(); var rhetosDocument = documentFactory.CreateNew(uri); rhetosDocument.UpdateText(text); var rootPathConfiguration = rhetosAppContext.GetRhetosProjectRootPath(rhetosDocument); Console.WriteLine($"\nRoot Path Configuration:\n{rootPathConfiguration?.ConfigurationType} = {rootPathConfiguration?.RootPath}\n from {rootPathConfiguration?.Context}"); Assert.AreEqual(expectedConfigurationType, rootPathConfiguration.ConfigurationType); if (expectedRootAppPath == null) { Assert.IsNull(rootPathConfiguration.RootPath); } else { if (rootPathConfiguration.ConfigurationType == RootPathConfigurationType.DetectedRhetosApp) { expectedRootAppPath = Path.Combine(Environment.CurrentDirectory, expectedRootAppPath); } Assert.AreEqual(expectedRootAppPath, rootPathConfiguration.RootPath); } }