Exemplo n.º 1
0
        public static string GetTestsCsProjFileText(bool addJwtAuth, string solutionDirectory, string projectBaseName)
        {
            var coreClassPath       = ClassPathHelper.CoreProjectClassPath(solutionDirectory, projectBaseName);
            var webApiClassPath     = ClassPathHelper.WebApiProjectClassPath(solutionDirectory, projectBaseName);
            var infraClassPath      = ClassPathHelper.InfrastructureProjectClassPath(solutionDirectory, projectBaseName);
            var sharedTestClassPath = ClassPathHelper.SharedTestProjectClassPath(solutionDirectory, projectBaseName);

            return(@$ "<Project Sdk=" "Microsoft.NET.Sdk" ">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include=" "AutoBogus" " Version=" "2.12.0" " />
    <PackageReference Include=" "Bogus" " Version=" "32.0.2" " />
    <PackageReference Include=" "Docker.DotNet" " Version=" "3.125.4" " />
    <PackageReference Include=" "FluentAssertions" " Version=" "5.10.3" " />
    <PackageReference Include=" "Microsoft.AspNetCore.Mvc.Testing" " Version=" "5.0.1" " />
    <PackageReference Include=" "MediatR" " Version=" "9.0.0" " />
    <PackageReference Include=" "Moq" " Version=" "4.16.1" " />
    <PackageReference Include=" "Newtonsoft.Json" " Version=" "12.0.3" " />
    <PackageReference Include=" "NUnit" " Version=" "3.12.0" " />
    <PackageReference Include=" "NUnit3TestAdapter" " Version=" "3.16.1" " />
    <PackageReference Include=" "Microsoft.NET.Test.Sdk" " Version=" "16.8.3" " />
    <PackageReference Include=" "Respawn" " Version=" "3.3.0" " />
    <PackageReference Include=" "WebMotions.Fake.Authentication.JwtBearer" " Version=" "3.1.0" " />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include=" "..\..\src\{coreClassPath.ClassNamespace}\{coreClassPath.ClassName}" " />
Exemplo n.º 2
0
        public static string GetTestsCsProjFileText(string solutionDirectory, string projectBaseName)
        {
            var coreClassPath       = ClassPathHelper.CoreProjectClassPath(solutionDirectory, projectBaseName);
            var sharedTestClassPath = ClassPathHelper.SharedTestProjectClassPath(solutionDirectory, projectBaseName);

            return(@$ "<Project Sdk=" "Microsoft.NET.Sdk" ">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include=" "AutoBogus" " Version=" "2.12.0" " />
    <PackageReference Include=" "Bogus" " Version=" "32.0.2" " />
    <PackageReference Include=" "FluentAssertions" " Version=" "5.10.3" " />
    <PackageReference Include=" "Microsoft.AspNetCore.Mvc.Testing" " Version=" "5.0.1" " />
    <PackageReference Include=" "Moq" " Version=" "4.16.1" " />
    <PackageReference Include=" "NUnit" " Version=" "3.12.0" " />
    <PackageReference Include=" "NUnit3TestAdapter" " Version=" "3.16.1" " />
    <PackageReference Include=" "Microsoft.NET.Test.Sdk" " Version=" "16.8.3" " />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include=" "..\..\src\{coreClassPath.ClassNamespace}\{coreClassPath.ClassName}" " />
Exemplo n.º 3
0
        public static void CreateCoreCsProj(string solutionDirectory, string solutionName)
        {
            try
            {
                var classPath = ClassPathHelper.CoreProjectClassPath(solutionDirectory, solutionName);

                if (!Directory.Exists(classPath.ClassDirectory))
                {
                    Directory.CreateDirectory(classPath.ClassDirectory);
                }

                if (File.Exists(classPath.FullClassPath))
                {
                    throw new FileAlreadyExistsException(classPath.FullClassPath);
                }

                using (FileStream fs = File.Create(classPath.FullClassPath))
                {
                    var data = "";
                    data = GetCoreCsProjFileText();
                    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;
            }
        }
Exemplo n.º 4
0
        public static string GetWebApiCsProjFileText(string solutionDirectory, string projectBaseName)
        {
            var coreClassPath  = ClassPathHelper.CoreProjectClassPath(solutionDirectory, projectBaseName);
            var infraClassPath = ClassPathHelper.InfrastructureProjectClassPath(solutionDirectory, projectBaseName);

            return(@$ "<Project Sdk=" "Microsoft.NET.Sdk.Web" ">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <PropertyGroup Condition=" "'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" ">
    <DocumentationFile></DocumentationFile>
    <NoWarn>1701;1702;</NoWarn>
Exemplo n.º 5
0
        public static string GetInfrastructurePersistenceCsProjFileText(string solutionDirectory, string projectBaseName)
        {
            var coreClassPath = ClassPathHelper.CoreProjectClassPath(solutionDirectory, projectBaseName);

            return(@$ "<Project Sdk=" "Microsoft.NET.Sdk" ">

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include=" "AutoBogus" " Version=" "2.12.0" " />
    <PackageReference Include=" "Bogus" " Version=" "32.0.2" " />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include=" "..\..\src\{coreClassPath.ClassNamespace}\{coreClassPath.ClassName}" " />
Exemplo n.º 6
0
        private static void BuildCoreProject(string solutionDirectory, string projectDirectory, string projectBaseName, IFileSystem fileSystem)
        {
            var solutionFolder       = projectDirectory.Replace(solutionDirectory, "").Replace(Path.DirectorySeparatorChar.ToString(), "");
            var coreProjectClassPath = ClassPathHelper.CoreProjectClassPath(projectDirectory, projectBaseName);

            CoreCsProjBuilder.CreateCoreCsProj(projectDirectory, projectBaseName);
            Utilities.ExecuteProcess("dotnet", $@"sln add ""{coreProjectClassPath.FullClassPath}"" --solution-folder {solutionFolder}", solutionDirectory);

            // dir won't show up in project until file is added
            Directory.CreateDirectory(ClassPathHelper.EntityClassPath(projectDirectory, "", projectBaseName).ClassDirectory);
            Directory.CreateDirectory(ClassPathHelper.DtoClassPath(projectDirectory, "", "", projectBaseName).ClassDirectory);
            Directory.CreateDirectory(ClassPathHelper.CoreExceptionClassPath(projectDirectory, "", projectBaseName).ClassDirectory);
            Directory.CreateDirectory(ClassPathHelper.WrappersClassPath(projectDirectory, "", projectBaseName).ClassDirectory);
            Directory.CreateDirectory(ClassPathHelper.SharedDtoClassPath(projectDirectory, "", projectBaseName).ClassDirectory);

            BasePaginationParametersBuilder.CreateBasePaginationParameters(projectDirectory, projectBaseName, fileSystem);
            PagedListBuilder.CreatePagedList(projectDirectory, projectBaseName, fileSystem);
            ResponseBuilder.CreateResponse(projectDirectory, projectBaseName, fileSystem);
            CoreExceptionsBuilder.CreateExceptions(projectDirectory, projectBaseName);
        }
Exemplo n.º 7
0
        public static string GetInfrastructurePersistenceCsProjFileText(string solutionDirectory, string projectBaseName, string dbProvider)
        {
            var coreClassPath = ClassPathHelper.CoreProjectClassPath(solutionDirectory, projectBaseName);
            var sqlPackage    = @$ "<PackageReference Include=" "Microsoft.EntityFrameworkCore.SqlServer" " Version=" "5.0.0" " />";

            if (Enum.GetName(typeof(DbProvider), DbProvider.Postgres) == dbProvider)
            {
                sqlPackage = @$ "<PackageReference Include=" "npgsql.entityframeworkcore.postgresql" " Version=" "5.0.0" " />";
            }
            //else if (Enum.GetName(typeof(DbProvider), DbProvider.MySql) == provider)
            //    return "UseMySql";

            return(@$ "<Project Sdk=" "Microsoft.NET.Sdk" ">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include=" "AutoBogus" " Version=" "2.12.0" " />
    <PackageReference Include=" "Bogus" " Version=" "32.0.2" " />
    <PackageReference Include=" "Microsoft.EntityFrameworkCore" " Version=" "5.0.1" " />
    <PackageReference Include=" "Microsoft.EntityFrameworkCore.InMemory" " Version=" "5.0.1" " />
    {sqlPackage}