diff --git a/CodeBuilder.slnx b/CodeBuilder.slnx index 14a4a5d..f575762 100644 --- a/CodeBuilder.slnx +++ b/CodeBuilder.slnx @@ -20,5 +20,6 @@ + diff --git a/Directory.Build.props b/Directory.Build.props index 3c5fd1e..2d8f37c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,7 +9,7 @@ 2024 <_DefaultTargetFrameworks>net8.0;net9.0;net10.0 <_ProjectTargetFrameworks>netstandard2.0;netstandard2.1;$(_DefaultTargetFrameworks) - <_TestTargetFrameworks>net6.0;net7.0;$(_DefaultTargetFrameworks) + <_TestTargetFrameworks>$(_DefaultTargetFrameworks) false diff --git a/Directory.Packages.props b/Directory.Packages.props index c0e4400..715be31 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -18,5 +18,7 @@ + + diff --git a/src/NetEvolve.CodeBuilder/CSharpCodeBuilder.Documentation.cs b/src/NetEvolve.CodeBuilder/CSharpCodeBuilder.Documentation.cs index 380d2a0..3ba57a8 100644 --- a/src/NetEvolve.CodeBuilder/CSharpCodeBuilder.Documentation.cs +++ b/src/NetEvolve.CodeBuilder/CSharpCodeBuilder.Documentation.cs @@ -1,6 +1,5 @@ namespace NetEvolve.CodeBuilder; -using System; using System.Collections.Generic; using System.Runtime.CompilerServices; diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.ComplexGeneration.cs b/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.ComplexGeneration.cs new file mode 100644 index 0000000..58d4ad1 --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.ComplexGeneration.cs @@ -0,0 +1,86 @@ +namespace NetEvolve.CodeBuilder.Tests.Integration; + +public partial class CSharpCodeBuilderTests +{ + [Test] + public async Task GenerateCompleteClass_Should_ProduceCorrectOutput() + { + // Build a complete class with using statements, namespace, and methods + var builder = new CSharpCodeBuilder() + .AppendLine("using System;") + .AppendLine("using System.Collections.Generic;") + .AppendLine() + .AppendLine("namespace MyApplication.Models") + .Append("{") + .AppendLine("/// ") + .AppendLine("/// Represents a customer entity.") + .AppendLine("/// ") + .AppendLine("public class Customer") + .Append("{") + .AppendLine("private readonly string _id;") + .AppendLine() + .AppendLine("/// ") + .AppendLine("/// Initializes a new instance of the Customer class.") + .AppendLine("/// ") + .AppendLine("/// The customer identifier.") + .AppendLine("public Customer(string id)") + .Append("{") + .AppendLine("_id = id ?? throw new ArgumentNullException(nameof(id));") + .Append("}") + .AppendLine() + .AppendLine("/// ") + .AppendLine("/// Gets the customer identifier.") + .AppendLine("/// ") + .AppendLine("public string Id => _id;") + .AppendLine() + .AppendLine("/// ") + .AppendLine("/// Gets or sets the customer name.") + .AppendLine("/// ") + .AppendLine("public string? Name { get; set; }") + .AppendLine() + .AppendLine("/// ") + .AppendLine("/// Gets or sets the customer email address.") + .AppendLine("/// ") + .Append("public string? Email { get; set; }") + .Append("}") + .Append("}"); + + var result = builder.ToString(); + + _ = await Verify(result); + } + + [Test] + public async Task GenerateInterface_WithMultipleMethods_Should_ProduceCorrectOutput() + { + var builder = new CSharpCodeBuilder() + .AppendLine("using System;") + .AppendLine("using System.Threading.Tasks;") + .AppendLine() + .AppendLine("namespace MyApplication.Services") + .Append("{") + .AppendXmlDocSummary("Defines the contract for customer service operations.") + .AppendLine("public interface ICustomerService") + .Append("{") + .AppendXmlDocSummary("Gets a customer by their identifier.") + .AppendXmlDocParam("id", "The customer identifier.") + .AppendXmlDocReturns("The customer if found; otherwise, null.") + .AppendLine("Task GetCustomerAsync(string id);") + .AppendLine() + .AppendXmlDocSummary("Creates a new customer.") + .AppendXmlDocParam("customer", "The customer to create.") + .AppendXmlDocReturns("A task representing the asynchronous operation.") + .AppendLine("Task CreateCustomerAsync(Customer customer);") + .AppendLine() + .AppendXmlDocSummary("Updates an existing customer.") + .AppendXmlDocParam("customer", "The customer to update.") + .AppendXmlDocReturns("A task representing the asynchronous operation.") + .Append("Task UpdateCustomerAsync(Customer customer);") + .Append("}") + .Append("}"); + + var result = builder.ToString(); + + _ = await Verify(result); + } +} diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.ConditionalGeneration.cs b/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.ConditionalGeneration.cs new file mode 100644 index 0000000..6afe86d --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.ConditionalGeneration.cs @@ -0,0 +1,165 @@ +namespace NetEvolve.CodeBuilder.Tests.Integration; + +using System.Globalization; +using System.Linq; + +public partial class CSharpCodeBuilderTests +{ + [Test] + public async Task GenerateMethodWithConditionalContent_Should_ProduceCorrectOutput() + { + var builder = new CSharpCodeBuilder(); + + var includeLogging = true; + var includeValidation = false; + var isAsync = true; + + _ = builder.AppendLine("public class ServiceClass").Append("{"); + + if (isAsync) + { + _ = builder.Append("public async Task"); + } + else + { + _ = builder.Append("public void"); + } + + _ = builder + .Append(" ProcessDataAsync(string input)") + .Append("{") + .AppendLineIf(includeValidation, "if (string.IsNullOrEmpty(input))") + .AppendLineIf(includeValidation, "{") + .AppendLineIf( + includeValidation, + " throw new ArgumentException(\"Input cannot be null or empty\", nameof(input));" + ) + .AppendLineIf(includeValidation, "}") + .AppendLineIf(includeValidation, "") + .AppendLineIf(includeLogging, "Console.WriteLine($\"Processing input: {input}\");") + .AppendLine("var result = input.ToUpperInvariant();") + .AppendLineIf(includeLogging, "Console.WriteLine($\"Processing complete: {result}\");") + .AppendLineIf(isAsync, "await Task.CompletedTask;") + .AppendLine("return result;") + .Append("}") + .Append("}"); + + var result = builder.ToString(); + + _ = await Verify(result); + } + + [Test] + public async Task GenerateReflectionBasedCode_Should_ProduceCorrectOutput() + { + var builder = new CSharpCodeBuilder(); + + var properties = new[] + { + new + { + Name = "Id", + Type = "int", + HasGetter = true, + HasSetter = false, + }, + new + { + Name = "Name", + Type = "string?", + HasGetter = true, + HasSetter = true, + }, + new + { + Name = "Email", + Type = "string?", + HasGetter = true, + HasSetter = true, + }, + new + { + Name = "CreatedAt", + Type = "DateTime", + HasGetter = true, + HasSetter = false, + }, + }; + + _ = builder.AppendLine("using System;").AppendLine().AppendLine("public class GeneratedEntity").Append("{"); + + // Generate backing fields for properties without setters + foreach (var prop in properties.Where(p => !p.HasSetter)) + { + _ = builder + .AppendFormat( + CultureInfo.InvariantCulture, + "private readonly {0} _{1};", + prop.Type, + prop.Name.ToUpperInvariant() + ) + .AppendLine(); + } + + if (properties.Any(p => !p.HasSetter)) + { + _ = builder.AppendLine(); + } + + // Generate constructor + var readOnlyProps = properties.Where(p => !p.HasSetter).ToArray(); + if (readOnlyProps.Length > 0) + { + _ = builder.Append("public GeneratedEntity("); + for (var i = 0; i < readOnlyProps.Length; i++) + { + if (i > 0) + { + _ = builder.Append(", "); + } + + _ = builder.AppendFormat( + CultureInfo.InvariantCulture, + "{0} {1}", + readOnlyProps[i].Type, + readOnlyProps[i].Name.ToUpperInvariant() + ); + } + _ = builder.AppendLine(")").Append("{"); + + foreach (var propertyName in readOnlyProps.Select(x => x.Name.ToUpperInvariant())) + { + _ = builder + .AppendFormat(CultureInfo.InvariantCulture, "_{0} = {1};", propertyName, propertyName) + .AppendLine(); + } + + _ = builder.Append("}").AppendLine(); + } + + // Generate properties + foreach (var prop in properties) + { + _ = builder.AppendFormat(CultureInfo.InvariantCulture, "public {0} {1}", prop.Type, prop.Name); + + if (prop.HasGetter && prop.HasSetter) + { + _ = builder.AppendLine(" { get; set; }"); + } + else if (prop.HasGetter && !prop.HasSetter) + { + _ = builder + .AppendFormat(CultureInfo.InvariantCulture, " => _{0};", prop.Name.ToUpperInvariant()) + .AppendLine(); + } + + _ = builder.AppendLine(); + } + + _ = builder.Append("}"); + + var result = builder.ToString(); + + _ = await Verify(result); + } +} diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.Formatting.cs b/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.Formatting.cs new file mode 100644 index 0000000..d6994aa --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.Formatting.cs @@ -0,0 +1,117 @@ +namespace NetEvolve.CodeBuilder.Tests.Integration; + +public partial class CSharpCodeBuilderTests +{ + [Test] + public async Task GenerateClassWithFormatting_UsingSpaces_Should_ProduceCorrectIndentation() + { + var builder = new CSharpCodeBuilder { UseTabs = false }; + + _ = builder + .AppendLine("public class TestClass") + .Append("{") + .AppendLine("public void Method1()") + .Append("{") + .AppendLine("Console.WriteLine(\"Hello World\");") + .AppendLine("if (true)") + .Append("{") + .Append("Console.WriteLine(\"Nested\");") + .Append("}") + .Append("}") + .AppendLine() + .AppendLine("public void Method2()") + .Append("{") + .Append("try") + .Append("{") + .Append("DoSomething();") + .Append("}") + .Append("catch (Exception ex)") + .Append("{") + .Append("Console.WriteLine($\"Error: {ex.Message}\");") + .Append("}") + .Append("}") + .Append("}"); + + var result = builder.ToString(); + + _ = await Verify(result); + } + + [Test] + public async Task GenerateClassWithFormatting_UsingTabs_Should_ProduceCorrectIndentation() + { + var builder = new CSharpCodeBuilder { UseTabs = true }; + + _ = builder + .AppendLine("public class TestClass") + .Append("{") + .AppendLine("public void Method1()") + .Append("{") + .AppendLine("Console.WriteLine(\"Hello World\");") + .AppendLine("if (true)") + .Append("{") + .Append("Console.WriteLine(\"Nested\");") + .Append("}") + .Append("}") + .AppendLine() + .AppendLine("public void Method2()") + .Append("{") + .Append("try") + .Append("{") + .Append("DoSomething();") + .Append("}") + .Append("catch (Exception ex)") + .Append("{") + .Append("Console.WriteLine($\"Error: {ex.Message}\");") + .Append("}") + .Append("}") + .Append("}"); + + var result = builder.ToString(); + + _ = await Verify(result); + } + + [Test] + public async Task GenerateEnum_WithDocumentation_Should_ProduceCorrectOutput() + { + var builder = new CSharpCodeBuilder(); + + _ = builder + .AppendLine("using System;") + .AppendLine() + .AppendLine("namespace MyApplication.Enums") + .Append("{") + .AppendLine("/// ") + .AppendLine("/// Represents the status of an order.") + .AppendLine("/// ") + .AppendLine("[Flags]") + .AppendLine("public enum OrderStatus") + .Append("{") + .AppendLine("/// ") + .AppendLine("/// The order is pending.") + .AppendLine("/// ") + .AppendLine("Pending = 1,") + .AppendLine() + .AppendLine("/// ") + .AppendLine("/// The order is being processed.") + .AppendLine("/// ") + .AppendLine("Processing = 2,") + .AppendLine() + .AppendLine("/// ") + .AppendLine("/// The order has been shipped.") + .AppendLine("/// ") + .AppendLine("Shipped = 4,") + .AppendLine() + .AppendLine("/// ") + .AppendLine("/// The order has been delivered.") + .AppendLine("/// ") + .Append("Delivered = 8") + .Append("}") + .Append("}"); + + var result = builder.ToString(); + + _ = await Verify(result); + } +} diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.SnapshotTests.cs b/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.SnapshotTests.cs new file mode 100644 index 0000000..a62998d --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.SnapshotTests.cs @@ -0,0 +1,43 @@ +namespace NetEvolve.CodeBuilder.Tests.Integration; + +public partial class CSharpCodeBuilderTests +{ + [Test] + public async Task GenerateCompleteClass_Should_MatchSnapshot() + { + var builder = new CSharpCodeBuilder(); + + // Build a complete class structure + _ = builder + .AppendLine("using System;") + .AppendLine("using System.Collections.Generic;") + .AppendLine() + .AppendLine("namespace MyApplication.Models") + .Append("{") + .AppendLine("public class Customer") + .Append("{") + .AppendLine("public string Id { get; set; }") + .Append("public string Name { get; set; }") + .Append("}") + .Append("}"); + + var result = builder.ToString(); + + _ = await Verify(result); + } + + [Test] + [MatrixDataSource] + public async Task GenerateWithDifferentFormats_Should_MatchSnapshots(bool useTabs) + { + // Test with spaces + var spacesBuilder = new CSharpCodeBuilder { UseTabs = useTabs }; + _ = spacesBuilder + .AppendLine("public class TestClass") + .Append("{") + .Append("public void Method() { }") + .Append("}"); + + _ = await Verify(spacesBuilder.ToString()).HashParameters().UseParameters(useTabs); + } +} diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.cs b/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.cs new file mode 100644 index 0000000..87f9424 --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderTests.cs @@ -0,0 +1,6 @@ +namespace NetEvolve.CodeBuilder.Tests.Integration; + +using NetEvolve.Extensions.TUnit; + +[TestGroup(nameof(CSharpCodeBuilder))] +public partial class CSharpCodeBuilderTests { } diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/NetEvolve.CodeBuilder.Tests.Integration.csproj b/tests/NetEvolve.CodeBuilder.Tests.Integration/NetEvolve.CodeBuilder.Tests.Integration.csproj new file mode 100644 index 0000000..b7e1bdf --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/NetEvolve.CodeBuilder.Tests.Integration.csproj @@ -0,0 +1,22 @@ + + + $(_TestTargetFrameworks) + Exe + true + $(NoWarn);CA2000;S2930 + true + + + + + + + + + + + + + + + diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/Startup.cs b/tests/NetEvolve.CodeBuilder.Tests.Integration/Startup.cs new file mode 100644 index 0000000..274fb46 --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/Startup.cs @@ -0,0 +1,22 @@ +namespace NetEvolve.CodeBuilder.Tests.Integration; + +using System.Runtime.CompilerServices; +using VerifyTUnit; + +internal static class Startup +{ + [ModuleInitializer] + public static void Initialize() + { + Verifier.DerivePathInfo( + (sourceFile, projectDirectory, type, method) => + { + var directory = Path.Combine(projectDirectory, "_snapshots"); + _ = Directory.CreateDirectory(directory); + return new(directory, type.Name, method.Name); + } + ); + + VerifierSettings.AutoVerify(includeBuildServer: false); + } +} diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateClassWithFormatting_UsingSpaces_Should_ProduceCorrectIndentation.verified.txt b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateClassWithFormatting_UsingSpaces_Should_ProduceCorrectIndentation.verified.txt new file mode 100644 index 0000000..4a16bd3 --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateClassWithFormatting_UsingSpaces_Should_ProduceCorrectIndentation.verified.txt @@ -0,0 +1,19 @@ +public class TestClass +{ + public void Method1() + { + Console.WriteLine("Hello World"); + if (true) + { + Console.WriteLine("Nested"); + } + } + public void Method2() + { + try{ + DoSomething(); + }catch (Exception ex){ + Console.WriteLine($"Error: {ex.Message}"); + } + } +} \ No newline at end of file diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateClassWithFormatting_UsingTabs_Should_ProduceCorrectIndentation.verified.txt b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateClassWithFormatting_UsingTabs_Should_ProduceCorrectIndentation.verified.txt new file mode 100644 index 0000000..94d0ddc --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateClassWithFormatting_UsingTabs_Should_ProduceCorrectIndentation.verified.txt @@ -0,0 +1,19 @@ +public class TestClass +{ + public void Method1() + { + Console.WriteLine("Hello World"); + if (true) + { + Console.WriteLine("Nested"); + } + } + public void Method2() + { + try{ + DoSomething(); + }catch (Exception ex){ + Console.WriteLine($"Error: {ex.Message}"); + } + } +} \ No newline at end of file diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateCompleteClass_Should_MatchSnapshot.verified.txt b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateCompleteClass_Should_MatchSnapshot.verified.txt new file mode 100644 index 0000000..d164a1e --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateCompleteClass_Should_MatchSnapshot.verified.txt @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace MyApplication.Models +{ + public class Customer + { + public string Id { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateCompleteClass_Should_ProduceCorrectOutput.verified.txt b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateCompleteClass_Should_ProduceCorrectOutput.verified.txt new file mode 100644 index 0000000..4a96ddd --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateCompleteClass_Should_ProduceCorrectOutput.verified.txt @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + +namespace MyApplication.Models +{ + /// + /// Represents a customer entity. + /// + public class Customer + { + private readonly string _id; + + /// + /// Initializes a new instance of the Customer class. + /// + /// The customer identifier. + public Customer(string id) + { + _id = id ?? throw new ArgumentNullException(nameof(id)); + + } + /// + /// Gets the customer identifier. + /// + public string Id => _id; + + /// + /// Gets or sets the customer name. + /// + public string? Name { get; set; } + + /// + /// Gets or sets the customer email address. + /// + public string? Email { get; set; } + } +} \ No newline at end of file diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateEnum_WithDocumentation_Should_ProduceCorrectOutput.verified.txt b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateEnum_WithDocumentation_Should_ProduceCorrectOutput.verified.txt new file mode 100644 index 0000000..3a00a9e --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateEnum_WithDocumentation_Should_ProduceCorrectOutput.verified.txt @@ -0,0 +1,31 @@ +using System; + +namespace MyApplication.Enums +{ + /// + /// Represents the status of an order. + /// + [Flags] + public enum OrderStatus + { + /// + /// The order is pending. + /// + Pending = 1, + + /// + /// The order is being processed. + /// + Processing = 2, + + /// + /// The order has been shipped. + /// + Shipped = 4, + + /// + /// The order has been delivered. + /// + Delivered = 8 + } +} \ No newline at end of file diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateInterface_WithMultipleMethods_Should_ProduceCorrectOutput.verified.txt b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateInterface_WithMultipleMethods_Should_ProduceCorrectOutput.verified.txt new file mode 100644 index 0000000..b927e3c --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateInterface_WithMultipleMethods_Should_ProduceCorrectOutput.verified.txt @@ -0,0 +1,32 @@ +using System; +using System.Threading.Tasks; + +namespace MyApplication.Services +{ + /// + /// Defines the contract for customer service operations. + /// + public interface ICustomerService + { + /// + /// Gets a customer by their identifier. + /// + /// The customer identifier. + /// The customer if found; otherwise, null. + Task GetCustomerAsync(string id); + + /// + /// Creates a new customer. + /// + /// The customer to create. + /// A task representing the asynchronous operation. + Task CreateCustomerAsync(Customer customer); + + /// + /// Updates an existing customer. + /// + /// The customer to update. + /// A task representing the asynchronous operation. + Task UpdateCustomerAsync(Customer customer); + } +} \ No newline at end of file diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateMethodWithConditionalContent_Should_ProduceCorrectOutput.verified.txt b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateMethodWithConditionalContent_Should_ProduceCorrectOutput.verified.txt new file mode 100644 index 0000000..9e7e44b --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateMethodWithConditionalContent_Should_ProduceCorrectOutput.verified.txt @@ -0,0 +1,11 @@ +public class ServiceClass +{ + public async Task ProcessDataAsync(string input){ + Console.WriteLine($"Processing input: {input}"); + var result = input.ToUpperInvariant(); + Console.WriteLine($"Processing complete: {result}"); + await Task.CompletedTask; + return result; + + } +} \ No newline at end of file diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateReflectionBasedCode_Should_ProduceCorrectOutput.verified.txt b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateReflectionBasedCode_Should_ProduceCorrectOutput.verified.txt new file mode 100644 index 0000000..f4150dc --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateReflectionBasedCode_Should_ProduceCorrectOutput.verified.txt @@ -0,0 +1,23 @@ +using System; + +public class GeneratedEntity +{ + private readonly int _ID; + private readonly DateTime _CREATEDAT; + + public GeneratedEntity(int ID, DateTime CREATEDAT) + { + _ID = ID; + _CREATEDAT = CREATEDAT; + + } + public int Id => _ID; + + public string? Name { get; set; } + + public string? Email { get; set; } + + public DateTime CreatedAt => _CREATEDAT; + + +} \ No newline at end of file diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateWithDifferentFormats_Should_MatchSnapshots_02b3255120757173.verified.txt b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateWithDifferentFormats_Should_MatchSnapshots_02b3255120757173.verified.txt new file mode 100644 index 0000000..271daf7 --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateWithDifferentFormats_Should_MatchSnapshots_02b3255120757173.verified.txt @@ -0,0 +1,4 @@ +public class TestClass +{ + public void Method() { } +} \ No newline at end of file diff --git a/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateWithDifferentFormats_Should_MatchSnapshots_b6b4547aad375c78.verified.txt b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateWithDifferentFormats_Should_MatchSnapshots_b6b4547aad375c78.verified.txt new file mode 100644 index 0000000..76924e7 --- /dev/null +++ b/tests/NetEvolve.CodeBuilder.Tests.Integration/_snapshots/CSharpCodeBuilderTests.GenerateWithDifferentFormats_Should_MatchSnapshots_b6b4547aad375c78.verified.txt @@ -0,0 +1,4 @@ +public class TestClass +{ + public void Method() { } +} \ No newline at end of file