From 257574173e808a5df4f6c555b41828a2c4e29554 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Feb 2026 10:12:06 +0000 Subject: [PATCH] Add unit tests for ToCamelCaseWithNamespace method Co-authored-by: enisn <23705418+enisn@users.noreply.github.com> --- .../Building/Steps/SolutionRenamer_Tests.cs | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/ProjectBuilding/Building/Steps/SolutionRenamer_Tests.cs diff --git a/framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/ProjectBuilding/Building/Steps/SolutionRenamer_Tests.cs b/framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/ProjectBuilding/Building/Steps/SolutionRenamer_Tests.cs new file mode 100644 index 0000000000..a3c5cee0d6 --- /dev/null +++ b/framework/test/Volo.Abp.Cli.Core.Tests/Volo/Abp/Cli/ProjectBuilding/Building/Steps/SolutionRenamer_Tests.cs @@ -0,0 +1,87 @@ +using Shouldly; +using System.Collections.Generic; +using System.Reflection; +using Volo.Abp.Cli.ProjectBuilding.Files; +using Xunit; + +namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps; + +public class SolutionRenamer_Tests +{ + [Theory] + [InlineData("Demo", "demo")] + [InlineData("MyCompany", "myCompany")] + [InlineData("Acme", "acme")] + [InlineData("ABC", "aBC")] + public void ToCamelCaseWithNamespace_Should_Handle_Single_Segment_Names(string input, string expected) + { + // Act + var result = InvokeToCamelCaseWithNamespace(input); + + // Assert + result.ShouldBe(expected); + } + + [Theory] + [InlineData("Demo.App", "demo.app")] + [InlineData("MyCompany.MyProject", "myCompany.myProject")] + [InlineData("Acme.Bookstore", "acme.bookstore")] + [InlineData("ABC.XYZ", "aBC.xYZ")] + public void ToCamelCaseWithNamespace_Should_Handle_Two_Segment_Names(string input, string expected) + { + // Act + var result = InvokeToCamelCaseWithNamespace(input); + + // Assert + result.ShouldBe(expected); + } + + [Theory] + [InlineData("Demo.App.QoL", "demo.app.qoL")] + [InlineData("MyCompany.MyProject.Module", "myCompany.myProject.module")] + [InlineData("Acme.Bookstore.Application", "acme.bookstore.application")] + [InlineData("A.B.C.D", "a.b.c.d")] + public void ToCamelCaseWithNamespace_Should_Handle_Multi_Segment_Names(string input, string expected) + { + // Act + var result = InvokeToCamelCaseWithNamespace(input); + + // Assert + result.ShouldBe(expected); + } + + [Theory] + [InlineData("", "")] + [InlineData("A", "a")] + [InlineData(".", ".")] + [InlineData("...", "...")] + public void ToCamelCaseWithNamespace_Should_Handle_Edge_Cases(string input, string expected) + { + // Act + var result = InvokeToCamelCaseWithNamespace(input); + + // Assert + result.ShouldBe(expected); + } + + [Fact] + public void ToCamelCaseWithNamespace_Should_Throw_On_Null_Input() + { + // Act & Assert + var exception = Should.Throw(() => InvokeToCamelCaseWithNamespace(null)); + exception.InnerException.ShouldBeOfType(); + } + + /// + /// Helper method to invoke the private static ToCamelCaseWithNamespace method using reflection + /// + private static string InvokeToCamelCaseWithNamespace(string input) + { + var type = typeof(SolutionRenamer); + var method = type.GetMethod("ToCamelCaseWithNamespace", BindingFlags.NonPublic | BindingFlags.Static); + + method.ShouldNotBeNull("ToCamelCaseWithNamespace method should exist"); + + return (string)method.Invoke(null, new object[] { input }); + } +}