Skip to content

Commit 13bc3b8

Browse files
Copilotsamtrion
andcommitted
Complete integration test project with documentation and snapshot test placeholders
Co-authored-by: samtrion <3283596+samtrion@users.noreply.github.com>
1 parent 8ed34d2 commit 13bc3b8

File tree

4 files changed

+132
-15
lines changed

4 files changed

+132
-15
lines changed

GitVersion.yml.backup

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

src/NetEvolve.CodeBuilder/NetEvolve.CodeBuilder.csproj.backup

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
namespace NetEvolve.CodeBuilder.Tests.Integration;
2+
3+
using System;
4+
5+
// TODO: Enable when Verify.TUnit compatibility is resolved in the target framework environment
6+
// using Verify.TUnit;
7+
8+
public partial class CSharpCodeBuilderIntegrationTests
9+
{
10+
// TODO: Uncomment and implement snapshot tests when Verify.TUnit is available
11+
/*
12+
[Test]
13+
public async Task GenerateCompleteClass_Should_MatchSnapshot()
14+
{
15+
var builder = new CSharpCodeBuilder();
16+
17+
// Build a complete class structure
18+
builder
19+
.AppendLine("using System;")
20+
.AppendLine("using System.Collections.Generic;")
21+
.AppendLine()
22+
.AppendLine("namespace MyApplication.Models")
23+
.Append("{")
24+
.AppendLine("public class Customer")
25+
.Append("{")
26+
.AppendLine("public string Id { get; set; }")
27+
.AppendLine("public string Name { get; set; }")
28+
.Append("}")
29+
.Append("}");
30+
31+
var result = builder.ToString();
32+
33+
// This would create and verify against a .verified.txt snapshot file
34+
await this.Verify(result);
35+
}
36+
37+
[Test]
38+
public async Task GenerateWithDifferentFormats_Should_MatchSnapshots()
39+
{
40+
// Test with spaces
41+
var spacesBuilder = new CSharpCodeBuilder { UseTabs = false };
42+
spacesBuilder
43+
.AppendLine("public class TestClass")
44+
.Append("{")
45+
.AppendLine("public void Method() { }")
46+
.Append("}");
47+
48+
await this.Verify(spacesBuilder.ToString())
49+
.UseParameters("spaces");
50+
51+
// Test with tabs
52+
var tabsBuilder = new CSharpCodeBuilder { UseTabs = true };
53+
tabsBuilder
54+
.AppendLine("public class TestClass")
55+
.Append("{")
56+
.AppendLine("public void Method() { }")
57+
.Append("}");
58+
59+
await this.Verify(tabsBuilder.ToString())
60+
.UseParameters("tabs");
61+
}
62+
*/
63+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# NetEvolve.CodeBuilder.Tests.Integration
2+
3+
This project contains integration tests for the NetEvolve.CodeBuilder library, focusing on end-to-end testing scenarios that validate the complete functionality of the code generation capabilities.
4+
5+
## Test Framework
6+
7+
- **TUnit**: Primary testing framework
8+
- **Verify.TUnit**: For snapshot testing (to be enabled when environment supports it)
9+
- **No Mocking**: Tests use real instances and validate actual output
10+
11+
## Test Organization
12+
13+
The integration tests are organized into partial classes for better maintainability:
14+
15+
### CSharpCodeBuilderIntegrationTests.ComplexGeneration.cs
16+
- Complete class generation with documentation
17+
- Interface generation with multiple methods
18+
- Real-world code generation scenarios
19+
20+
### CSharpCodeBuilderIntegrationTests.ConditionalGeneration.cs
21+
- Conditional content generation using AppendIf methods
22+
- Reflection-based code generation patterns
23+
- Dynamic property and method generation
24+
25+
### CSharpCodeBuilderIntegrationTests.Formatting.cs
26+
- Indentation testing (spaces vs tabs)
27+
- Code formatting validation
28+
- Enum generation with attributes
29+
30+
### CSharpCodeBuilderIntegrationTests.SnapshotTests.cs
31+
- Placeholder for snapshot tests using Verify.TUnit
32+
- Will be enabled when framework compatibility is resolved
33+
34+
## Test Scenarios
35+
36+
The integration tests cover:
37+
38+
1. **End-to-End Class Generation**: Complete C# classes with proper indentation, documentation, and structure
39+
2. **Interface Generation**: Service interfaces with async methods and documentation
40+
3. **Conditional Logic**: Using AppendIf and AppendLineIf for dynamic content
41+
4. **Formatting Options**: Testing both space and tab-based indentation
42+
5. **Complex Structures**: Enums with attributes, nested code blocks, exception handling
43+
44+
## Running Tests
45+
46+
```bash
47+
# Run all integration tests
48+
dotnet test tests/NetEvolve.CodeBuilder.Tests.Integration/
49+
50+
# Run specific test class
51+
dotnet test tests/NetEvolve.CodeBuilder.Tests.Integration/ --filter "ClassName=CSharpCodeBuilderIntegrationTests"
52+
```
53+
54+
## Adding New Tests
55+
56+
When adding new integration tests:
57+
58+
1. Follow the existing naming convention: `MethodName_Condition_Should_ExpectedResult`
59+
2. Use the [Test] attribute from TUnit
60+
3. Use partial classes to organize related tests
61+
4. Validate both content and formatting in assertions
62+
5. Include real-world scenarios that developers would encounter
63+
64+
## Future Enhancements
65+
66+
- Snapshot testing with Verify.TUnit when framework support is available
67+
- Performance benchmarking for large code generation scenarios
68+
- Cross-platform indentation testing
69+
- Template-based code generation tests

0 commit comments

Comments
 (0)