public static void CreateWebAppFactory(string solutionDirectory, string solutionName, string dbContextName, bool addJwtAuthentication) { try { var classPath = ClassPathHelper.FunctionalTestProjectRootClassPath(solutionDirectory, $"{Utilities.GetWebHostFactoryName()}.cs", solutionName); if (!Directory.Exists(classPath.ClassDirectory)) { Directory.CreateDirectory(classPath.ClassDirectory); } if (File.Exists(classPath.FullClassPath)) { File.Delete(classPath.FullClassPath); // saves me from having to make a remover! } using (FileStream fs = File.Create(classPath.FullClassPath)) { var data = GetWebAppFactoryFileText(classPath, dbContextName, solutionDirectory, solutionName, addJwtAuthentication); fs.Write(Encoding.UTF8.GetBytes(data)); } } catch (FileAlreadyExistsException e) { WriteError(e.Message); throw; } catch (Exception e) { WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}"); throw; } }
public static void CreateBase(string solutionDirectory, string projectBaseName, string dbContextName, IFileSystem fileSystem) { try { var classPath = ClassPathHelper.FunctionalTestProjectRootClassPath(solutionDirectory, "TestBase.cs", projectBaseName); if (!fileSystem.Directory.Exists(classPath.ClassDirectory)) { fileSystem.Directory.CreateDirectory(classPath.ClassDirectory); } if (fileSystem.File.Exists(classPath.FullClassPath)) { throw new FileAlreadyExistsException(classPath.FullClassPath); } using (var fs = fileSystem.File.Create(classPath.FullClassPath)) { var data = ""; data = GetBaseText(classPath.ClassNamespace, solutionDirectory, projectBaseName, dbContextName); fs.Write(Encoding.UTF8.GetBytes(data)); } } catch (FileAlreadyExistsException e) { WriteError(e.Message); throw; } catch (Exception e) { WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}"); throw; } }
private static void BuildFunctionalTestProject(string solutionDirectory, string testDirectory, string projectBaseName, bool addJwtAuth) { var solutionFolder = testDirectory.GetSolutionFolder(solutionDirectory); var testProjectClassPath = ClassPathHelper.FunctionalTestProjectRootClassPath(testDirectory, "", projectBaseName); FunctionalTestsCsProjBuilder.CreateTestsCsProj(testDirectory, projectBaseName, addJwtAuth); Utilities.ExecuteProcess("dotnet", $@"sln add ""{testProjectClassPath.FullClassPath}"" --solution-folder {solutionFolder}", solutionDirectory); }
public static void CreateWebAppFactory(string solutionDirectory, string projectName, string dbContextName, bool addJwtAuthentication) { var classPath = ClassPathHelper.FunctionalTestProjectRootClassPath(solutionDirectory, $"{Utilities.GetWebHostFactoryName()}.cs", projectName); if (!Directory.Exists(classPath.ClassDirectory)) { Directory.CreateDirectory(classPath.ClassDirectory); } if (File.Exists(classPath.FullClassPath)) { File.Delete(classPath.FullClassPath); // saves me from having to make a remover! } using (FileStream fs = File.Create(classPath.FullClassPath)) { var data = GetWebAppFactoryFileText(classPath, dbContextName, solutionDirectory, projectName, addJwtAuthentication); fs.Write(Encoding.UTF8.GetBytes(data)); } }
public static void CreateBase(string solutionDirectory, string projectBaseName, string dbContextName, IFileSystem fileSystem) { var classPath = ClassPathHelper.FunctionalTestProjectRootClassPath(solutionDirectory, "TestBase.cs", projectBaseName); if (!fileSystem.Directory.Exists(classPath.ClassDirectory)) { fileSystem.Directory.CreateDirectory(classPath.ClassDirectory); } if (fileSystem.File.Exists(classPath.FullClassPath)) { throw new FileAlreadyExistsException(classPath.FullClassPath); } using (var fs = fileSystem.File.Create(classPath.FullClassPath)) { var data = ""; data = GetBaseText(classPath.ClassNamespace, solutionDirectory, projectBaseName, dbContextName); fs.Write(Encoding.UTF8.GetBytes(data)); } }