Merge pull request #18346 from abpframework/AppTemplateRemoveMongodbCollectionFixtureStep

Remove `AppTemplateRemoveMongodbCollectionFixtureStep`.
pull/18349/head
Engincan VESKE 1 year ago committed by GitHub
commit ac4fd39fe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -107,7 +107,6 @@ public abstract class AppTemplateBase : TemplateInfo
if (context.BuildArgs.DatabaseProvider != DatabaseProvider.MongoDb)
{
steps.Add(new AppTemplateRemoveMongodbCollectionFixtureStep());
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.MongoDB"));
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.MongoDB.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests"));
}

@ -1,74 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Volo.Abp.Cli.ProjectBuilding.Building;
namespace Volo.Abp.Cli.ProjectBuilding.Templates.App;
public class AppTemplateRemoveMongodbCollectionFixtureStep : ProjectBuildPipelineStep
{
public override void Execute(ProjectBuildContext context)
{
if (context.Template.IsNoLayer())
{
return;
}
//MyCompanyName.MyProjectName.Application.Tests
RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationCollection.cs");
RemoveKeyword(context,
"/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppServiceTests.cs",
"[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]");
//MyCompanyName.MyProjectName.Domain.Tests
RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainCollection.cs");
RemoveKeyword(context,
"/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleDomainTests.cs",
"[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]");
//MyCompanyName.MyProjectName.EntityFrameworkCore.Tests
RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollection.cs");
RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollectionFixtureBase.cs");
RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreFixture.cs");
RemoveKeyword(context,
"/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs",
"[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]");
//MyCompanyName.MyProjectName.Web.Tests
RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebCollection.cs");
RemoveKeyword(context,
"/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/Pages/Index_Tests.cs",
"[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]");
//MyCompanyName.MyProjectName.TestBase
RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestConsts.cs");
}
private static void RemoveFile(ProjectBuildContext context, string targetModuleFilePath)
{
var file = context.Files.FirstOrDefault(x => x.Name == targetModuleFilePath);
if (file != null)
{
context.Files.Remove(file);
}
}
private static void RemoveKeyword(ProjectBuildContext context, string targetModuleFilePath, string keyword)
{
var file = context.GetFile(targetModuleFilePath);
file.NormalizeLineEndings();
var lines = file.GetLines();
var newLines = new List<string>();
for (var i = 0; i < lines.Length; i++)
{
if (!lines[i].Contains(keyword))
{
newLines.Add(lines[i]);
}
}
file.SetLines(newLines);
}
}
Loading…
Cancel
Save