Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed class Int_IsPositiveAsync_Assertion : Assertion<int>
var result = await value!.IsPositiveAsync();
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}"));
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
Expand Down Expand Up @@ -69,7 +69,7 @@ public sealed class Int_IsGreaterThanAsync_Int_Assertion : Assertion<int>
var result = await value!.IsGreaterThanAsync(_threshold);
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}"));
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed class Int_IsPositiveAsync_Assertion : Assertion<int>
var result = await value!.IsPositiveAsync();
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}"));
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
Expand Down Expand Up @@ -69,7 +69,7 @@ public sealed class Int_IsGreaterThanAsync_Int_Assertion : Assertion<int>
var result = await value!.IsGreaterThanAsync(_threshold);
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}"));
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed class Int_IsPositiveAsync_Assertion : Assertion<int>
var result = await value!.IsPositiveAsync();
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}"));
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
Expand Down Expand Up @@ -69,7 +69,7 @@ public sealed class Int_IsGreaterThanAsync_Int_Assertion : Assertion<int>
var result = await value!.IsGreaterThanAsync(_threshold);
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}"));
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed class Int_IsPositiveAsync_Assertion : Assertion<int>
var result = await value!.IsPositiveAsync();
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}"));
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
Expand Down Expand Up @@ -69,7 +69,7 @@ public sealed class Int_IsGreaterThanAsync_Int_Assertion : Assertion<int>
var result = await value!.IsGreaterThanAsync(_threshold);
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}"));
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public Task AsyncBoolMethod() => RunTest(
await Assert.That(mainFile).IsNotNull();
await Assert.That(mainFile!).Contains("IsPositiveAsync_Assertion");
await Assert.That(mainFile!).Contains("var result = await"); // Awaits Task<bool>
// The Task<bool> branch's failure-return must terminate with a single `);` —
// a `));` (two closing parens) is a literal C# syntax error that pins this
// assertion against the regression where the emit had an extra closing paren.
await Assert.That(mainFile!).DoesNotContain("Failed($\"found {value}\"));");
await Assert.That(mainFile!).Contains("Failed($\"found {value}\");");
});

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
[
// <auto-generated/>
#pragma warning disable
#nullable enable

using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using TUnit.Assertions.Core;
using TUnit.Assertions.Tests.TestData;

namespace TUnit.Assertions.Extensions;

/// <summary>
/// Generated assertion for IsPositiveAsync
/// </summary>
public sealed class Int_IsPositiveAsync_Assertion : Assertion<int>
{
public Int_IsPositiveAsync_Assertion(AssertionContext<int> context)
: base(context)
{
}

protected override async Task<AssertionResult> CheckAsync(EvaluationMetadata<int> metadata)
{
var value = metadata.Value;
var exception = metadata.Exception;

if (exception != null)
{
return AssertionResult.Failed($"threw {exception.GetType().FullName}");
}

var result = await value!.IsPositiveAsync();
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
{
return "to satisfy IsPositiveAsync";
}
}

/// <summary>
/// Generated assertion for IsGreaterThanAsync
/// </summary>
public sealed class Int_IsGreaterThanAsync_Int_Assertion : Assertion<int>
{
private readonly int _threshold;

public Int_IsGreaterThanAsync_Int_Assertion(AssertionContext<int> context, int threshold)
: base(context)
{
_threshold = threshold;
}

protected override async Task<AssertionResult> CheckAsync(EvaluationMetadata<int> metadata)
{
var value = metadata.Value;
var exception = metadata.Exception;

if (exception != null)
{
return AssertionResult.Failed($"threw {exception.GetType().FullName}");
}

var result = await value!.IsGreaterThanAsync(_threshold);
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
{
return $"to satisfy IsGreaterThanAsync({_threshold})";
}
}

public static partial class AsyncBoolAssertionExtensions
{
/// <summary>
/// Generated extension method for IsPositiveAsync
/// </summary>
public static Int_IsPositiveAsync_Assertion IsPositiveAsync(this IAssertionSource<int> source)
{
source.Context.ExpressionBuilder.Append(".IsPositiveAsync()");
return new Int_IsPositiveAsync_Assertion(source.Context);
}

/// <summary>
/// Generated extension method for IsGreaterThanAsync
/// </summary>
public static Int_IsGreaterThanAsync_Int_Assertion IsGreaterThanAsync(this IAssertionSource<int> source, int threshold, [CallerArgumentExpression(nameof(threshold))] string? thresholdExpression = null)
{
source.Context.ExpressionBuilder.Append($".IsGreaterThanAsync({thresholdExpression})");
return new Int_IsGreaterThanAsync_Int_Assertion(source.Context, threshold);
}

}

]
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
[
// <auto-generated/>
#pragma warning disable
#nullable enable

using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using TUnit.Assertions.Core;
using TUnit.Assertions.Tests.TestData;

namespace TUnit.Assertions.Extensions;

/// <summary>
/// Generated assertion for IsPositiveAsync
/// </summary>
public sealed class Int_IsPositiveAsync_Assertion : Assertion<int>
{
public Int_IsPositiveAsync_Assertion(AssertionContext<int> context)
: base(context)
{
}

protected override async Task<AssertionResult> CheckAsync(EvaluationMetadata<int> metadata)
{
var value = metadata.Value;
var exception = metadata.Exception;

if (exception != null)
{
return AssertionResult.Failed($"threw {exception.GetType().FullName}");
}

var result = await value!.IsPositiveAsync();
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
{
return "to satisfy IsPositiveAsync";
}
}

/// <summary>
/// Generated assertion for IsGreaterThanAsync
/// </summary>
public sealed class Int_IsGreaterThanAsync_Int_Assertion : Assertion<int>
{
private readonly int _threshold;

public Int_IsGreaterThanAsync_Int_Assertion(AssertionContext<int> context, int threshold)
: base(context)
{
_threshold = threshold;
}

protected override async Task<AssertionResult> CheckAsync(EvaluationMetadata<int> metadata)
{
var value = metadata.Value;
var exception = metadata.Exception;

if (exception != null)
{
return AssertionResult.Failed($"threw {exception.GetType().FullName}");
}

var result = await value!.IsGreaterThanAsync(_threshold);
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
{
return $"to satisfy IsGreaterThanAsync({_threshold})";
}
}

public static partial class AsyncBoolAssertionExtensions
{
/// <summary>
/// Generated extension method for IsPositiveAsync
/// </summary>
public static Int_IsPositiveAsync_Assertion IsPositiveAsync(this IAssertionSource<int> source)
{
source.Context.ExpressionBuilder.Append(".IsPositiveAsync()");
return new Int_IsPositiveAsync_Assertion(source.Context);
}

/// <summary>
/// Generated extension method for IsGreaterThanAsync
/// </summary>
public static Int_IsGreaterThanAsync_Int_Assertion IsGreaterThanAsync(this IAssertionSource<int> source, int threshold, [CallerArgumentExpression(nameof(threshold))] string? thresholdExpression = null)
{
source.Context.ExpressionBuilder.Append($".IsGreaterThanAsync({thresholdExpression})");
return new Int_IsGreaterThanAsync_Int_Assertion(source.Context, threshold);
}

}

]
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
[
// <auto-generated/>
#pragma warning disable
#nullable enable

using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using TUnit.Assertions.Core;
using TUnit.Assertions.Tests.TestData;

namespace TUnit.Assertions.Extensions;

/// <summary>
/// Generated assertion for IsPositiveAsync
/// </summary>
public sealed class Int_IsPositiveAsync_Assertion : Assertion<int>
{
public Int_IsPositiveAsync_Assertion(AssertionContext<int> context)
: base(context)
{
}

protected override async Task<AssertionResult> CheckAsync(EvaluationMetadata<int> metadata)
{
var value = metadata.Value;
var exception = metadata.Exception;

if (exception != null)
{
return AssertionResult.Failed($"threw {exception.GetType().FullName}");
}

var result = await value!.IsPositiveAsync();
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
{
return "to satisfy IsPositiveAsync";
}
}

/// <summary>
/// Generated assertion for IsGreaterThanAsync
/// </summary>
public sealed class Int_IsGreaterThanAsync_Int_Assertion : Assertion<int>
{
private readonly int _threshold;

public Int_IsGreaterThanAsync_Int_Assertion(AssertionContext<int> context, int threshold)
: base(context)
{
_threshold = threshold;
}

protected override async Task<AssertionResult> CheckAsync(EvaluationMetadata<int> metadata)
{
var value = metadata.Value;
var exception = metadata.Exception;

if (exception != null)
{
return AssertionResult.Failed($"threw {exception.GetType().FullName}");
}

var result = await value!.IsGreaterThanAsync(_threshold);
return result
? AssertionResult.Passed
: AssertionResult.Failed($"found {value}");
}

protected override string GetExpectation()
{
return $"to satisfy IsGreaterThanAsync({_threshold})";
}
}

public static partial class AsyncBoolAssertionExtensions
{
/// <summary>
/// Generated extension method for IsPositiveAsync
/// </summary>
public static Int_IsPositiveAsync_Assertion IsPositiveAsync(this IAssertionSource<int> source)
{
source.Context.ExpressionBuilder.Append(".IsPositiveAsync()");
return new Int_IsPositiveAsync_Assertion(source.Context);
}

/// <summary>
/// Generated extension method for IsGreaterThanAsync
/// </summary>
public static Int_IsGreaterThanAsync_Int_Assertion IsGreaterThanAsync(this IAssertionSource<int> source, int threshold, [CallerArgumentExpression(nameof(threshold))] string? thresholdExpression = null)
{
source.Context.ExpressionBuilder.Append($".IsGreaterThanAsync({thresholdExpression})");
return new Int_IsGreaterThanAsync_Int_Assertion(source.Context, threshold);
}

}

]
Loading
Loading