Skip to content

Commit 46da82c

Browse files
committed
chore(test): Updated tests
1 parent cdd967c commit 46da82c

File tree

22 files changed

+389
-333
lines changed

22 files changed

+389
-333
lines changed

Directory.Packages.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<PackageVersion Include="NetEvolve.Extensions.TUnit" Version="2.7.0" />
1919
<PackageVersion Include="System.Memory" Version="4.6.3" />
2020
<PackageVersion Include="TUnit" Version="0.57.1" />
21+
<PackageVersion Include="Verify.ParametersHashing" Version="1.0.0" />
2122
<PackageVersion Include="Verify.TUnit" Version="30.7.3" />
2223
</ItemGroup>
23-
</Project>
24+
</Project>

src/NetEvolve.CodeBuilder/CSharpCodeBuilder.Documentation.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace NetEvolve.CodeBuilder;
22

3-
using System;
43
using System.Collections.Generic;
54
using System.Runtime.CompilerServices;
65

tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderIntegrationTests.ComplexGeneration.cs

Lines changed: 0 additions & 122 deletions
This file was deleted.

tests/NetEvolve.CodeBuilder.Tests.Integration/CSharpCodeBuilderIntegrationTests.SnapshotTests.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
namespace NetEvolve.CodeBuilder.Tests.Integration;
2+
3+
public partial class CSharpCodeBuilderTests
4+
{
5+
[Test]
6+
public async Task GenerateCompleteClass_Should_ProduceCorrectOutput()
7+
{
8+
// Build a complete class with using statements, namespace, and methods
9+
var builder = new CSharpCodeBuilder()
10+
.AppendLine("using System;")
11+
.AppendLine("using System.Collections.Generic;")
12+
.AppendLine()
13+
.AppendLine("namespace MyApplication.Models")
14+
.Append("{")
15+
.AppendLine("/// <summary>")
16+
.AppendLine("/// Represents a customer entity.")
17+
.AppendLine("/// </summary>")
18+
.AppendLine("public class Customer")
19+
.Append("{")
20+
.AppendLine("private readonly string _id;")
21+
.AppendLine()
22+
.AppendLine("/// <summary>")
23+
.AppendLine("/// Initializes a new instance of the Customer class.")
24+
.AppendLine("/// </summary>")
25+
.AppendLine("/// <param name=\"id\">The customer identifier.</param>")
26+
.AppendLine("public Customer(string id)")
27+
.Append("{")
28+
.AppendLine("_id = id ?? throw new ArgumentNullException(nameof(id));")
29+
.Append("}")
30+
.AppendLine()
31+
.AppendLine("/// <summary>")
32+
.AppendLine("/// Gets the customer identifier.")
33+
.AppendLine("/// </summary>")
34+
.AppendLine("public string Id => _id;")
35+
.AppendLine()
36+
.AppendLine("/// <summary>")
37+
.AppendLine("/// Gets or sets the customer name.")
38+
.AppendLine("/// </summary>")
39+
.AppendLine("public string? Name { get; set; }")
40+
.AppendLine()
41+
.AppendLine("/// <summary>")
42+
.AppendLine("/// Gets or sets the customer email address.")
43+
.AppendLine("/// </summary>")
44+
.Append("public string? Email { get; set; }")
45+
.Append("}")
46+
.Append("}");
47+
48+
var result = builder.ToString();
49+
50+
_ = await Verify(result);
51+
}
52+
53+
[Test]
54+
public async Task GenerateInterface_WithMultipleMethods_Should_ProduceCorrectOutput()
55+
{
56+
var builder = new CSharpCodeBuilder()
57+
.AppendLine("using System;")
58+
.AppendLine("using System.Threading.Tasks;")
59+
.AppendLine()
60+
.AppendLine("namespace MyApplication.Services")
61+
.Append("{")
62+
.AppendXmlDocSummary("Defines the contract for customer service operations.")
63+
.AppendLine("public interface ICustomerService")
64+
.Append("{")
65+
.AppendXmlDocSummary("Gets a customer by their identifier.")
66+
.AppendXmlDocParam("id", "The customer identifier.")
67+
.AppendXmlDocReturns("The customer if found; otherwise, null.")
68+
.AppendLine("Task<Customer?> GetCustomerAsync(string id);")
69+
.AppendLine()
70+
.AppendXmlDocSummary("Creates a new customer.")
71+
.AppendXmlDocParam("customer", "The customer to create.")
72+
.AppendXmlDocReturns("A task representing the asynchronous operation.")
73+
.AppendLine("Task CreateCustomerAsync(Customer customer);")
74+
.AppendLine()
75+
.AppendXmlDocSummary("Updates an existing customer.")
76+
.AppendXmlDocParam("customer", "The customer to update.")
77+
.AppendXmlDocReturns("A task representing the asynchronous operation.")
78+
.Append("Task UpdateCustomerAsync(Customer customer);")
79+
.Append("}")
80+
.Append("}");
81+
82+
var result = builder.ToString();
83+
84+
_ = await Verify(result);
85+
}
86+
}

0 commit comments

Comments
 (0)