Skip to content

Commit 8d4475f

Browse files
committed
Fix: Parity with new tUnit update
1 parent 2bae5ea commit 8d4475f

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/CodeOfChaos.Testing.TUnit/CodeOfChaos.Testing.TUnit.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.12.0" />
3535
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
3636
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.12.0" />
37-
<PackageReference Include="TUnit.Assertions" Version="0.10.19" />
38-
<PackageReference Include="TUnit.Core" Version="0.10.19" />
37+
<PackageReference Include="TUnit.Assertions" Version="0.12.14" />
38+
<PackageReference Include="TUnit.Core" Version="0.12.14" />
3939
</ItemGroup>
4040

4141
</Project>

src/CodeOfChaos.Testing.TUnit/Conditions/GeneratorDriverRunResultHasSourceTextEqualToCondition.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@ namespace CodeOfChaos.Testing.TUnit.Conditions;
1010
// Code
1111
// ---------------------------------------------------------------------------------------------------------------------
1212
public class GeneratorDriverRunResultHasSourceTextEqualToCondition(string filename, string expected, StringComparison stringComparison, bool ignoreWhiteSpace, bool withTrimming)
13-
: ExpectedValueAssertCondition<GeneratorDriverRunResult, string>(expected) {
14-
private readonly string _expected = expected;
13+
: BaseAssertCondition<GeneratorDriverRunResult> {
1514

1615
// -----------------------------------------------------------------------------------------------------------------
1716
// Methods
1817
// -----------------------------------------------------------------------------------------------------------------
1918
protected override string GetExpectation() => throw new NotImplementedException();
20-
protected override async Task<AssertionResult> GetResult(GeneratorDriverRunResult? runResult, string? expectedValue) {
21-
if (runResult is null) return AssertionResult.Fail("Compilation is null");
22-
if (expectedValue is null) return AssertionResult.Fail("Expected string is null");
19+
protected override async Task<AssertionResult> GetResult(GeneratorDriverRunResult? actualValue, Exception? exception, AssertionMetadata assertionMetadata) {
20+
if (actualValue is null) return AssertionResult.Fail("Compilation is null");
2321

24-
GeneratedSourceResult? generatedSource = runResult.Results
22+
GeneratedSourceResult? generatedSource = actualValue.Results
2523
.SelectMany(result => result.GeneratedSources)
2624
.SingleOrDefault(result => result.HintName == filename);
2725

@@ -32,10 +30,10 @@ protected override async Task<AssertionResult> GetResult(GeneratorDriverRunResul
3230
string sourceTextString = sourceText.ToString();
3331

3432
// Use the TUnit Equals String so it follows the same structure
35-
var stringEqualsAssertCondition = new StringEqualsExpectedValueAssertCondition(_expected, stringComparison);
33+
var stringEqualsAssertCondition = new StringEqualsExpectedValueAssertCondition(expected, stringComparison);
3634
if (withTrimming) stringEqualsAssertCondition.WithTrimming();
3735
if (ignoreWhiteSpace) stringEqualsAssertCondition.IgnoringWhitespace();
3836

39-
return await stringEqualsAssertCondition.GetAssertionResult(sourceTextString, null);
37+
return await stringEqualsAssertCondition.GetAssertionResult(sourceTextString,null, assertionMetadata);
4038
}
4139
}

tests/Tests.CodeOfChaos.Testing.TUnit/Tests.CodeOfChaos.Testing.TUnit.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ItemGroup>
1414
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
1515
<PackageReference Include="Moq" Version="4.20.72"/>
16-
<PackageReference Include="TUnit" Version="0.10.19"/>
16+
<PackageReference Include="TUnit" Version="0.12.14" />
1717
<PackageReference Include="Bogus" Version="35.6.1"/>
1818
</ItemGroup>
1919

0 commit comments

Comments
 (0)