public async Task MergeJsonFiles_NoFileFound() { var testDir = Path.Combine(new AppSettings().BaseDirectoryProject, "_not_found"); var result = await SetupAppSettings.MergeJsonFiles(testDir); Assert.AreEqual(result.Verbose, new AppSettings().Verbose); }
public async Task MergeJsonFiles_StackFromEnv() { var testDir = Path.Combine(new AppSettings().BaseDirectoryProject, "_test"); _hostStorage.FolderDelete(testDir); _hostStorage.CreateDirectory(testDir); await _hostStorage.WriteStreamAsync(new PlainTextFileHelper().StringToStream( "{\n \"app\": {\n " + " \"StorageFolder\": \"/data/test\",\n \"addSwagger\": \"true\" " + " }\n}\n"), Path.Combine(testDir, "appsettings.json")); await _hostStorage.WriteStreamAsync(new PlainTextFileHelper().StringToStream( "{\n \"app\": {\n \"addSwagger\": \"false\" " + " }\n}\n"), Path.Combine(testDir, "appsettings_ref_patch.json")); Environment.SetEnvironmentVariable("app__appsettingspath", Path.Combine(testDir, "appsettings_ref_patch.json")); var result = await SetupAppSettings.MergeJsonFiles(testDir); Assert.AreEqual(PathHelper.AddBackslash("/data/test"), result.StorageFolder); Assert.AreEqual(false, result.AddSwagger); Environment.SetEnvironmentVariable("app__appsettingspath", null); }
public async Task MergeJsonFiles_DefaultFile() { var testDir = Path.Combine(new AppSettings().BaseDirectoryProject, "_test"); if (_hostStorage.ExistFolder(testDir)) { _hostStorage.FolderDelete(testDir); } _hostStorage.CreateDirectory(testDir); await _hostStorage.WriteStreamAsync(new PlainTextFileHelper().StringToStream( "{\n \"app\": {\n " + " \"StorageFolder\": \"/data/test\"\n " + " }\n}\n"), Path.Combine(testDir, "appsettings.json")); var result = await SetupAppSettings.MergeJsonFiles(testDir); Assert.AreEqual(PathHelper.AddBackslash("/data/test"), result.StorageFolder); }