Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion Source/aweXpect.Core/Delegates/ThatDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public override ConstraintResult Negate()
=> this;
}

internal class ThrowsOption
public class ThrowsOption
{
public bool DoCheckThrow { get; private set; } = true;

Expand Down
4 changes: 2 additions & 2 deletions Source/aweXpect.Core/Delegates/ThatDelegateThrows.OnlyIf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class ThatDelegateThrows<TException>
/// </summary>
public ThatDelegateThrows<TException?> OnlyIf(bool predicate)
{
_throwOptions.CheckThrow(predicate);
return new ThatDelegateThrows<TException?>(ExpectationBuilder, _throwOptions);
ThrowOptions.CheckThrow(predicate);
return new ThatDelegateThrows<TException?>(ExpectationBuilder, ThrowOptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ThatDelegateThrows<TException> Within(TimeSpan duration)

TimeSpanEqualityOptions options = new();
options.Within(duration);
_throwOptions.ExecutionTimeOptions = options;
ThrowOptions.ExecutionTimeOptions = options;
return this;
}
}
20 changes: 9 additions & 11 deletions Source/aweXpect.Core/Delegates/ThatDelegateThrows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,19 @@ namespace aweXpect.Delegates;
/// <summary>
/// An <see cref="ExpectationResult" /> when an exception was thrown.
/// </summary>
public partial class ThatDelegateThrows<TException>
: ExpectationResult<TException, ThatDelegateThrows<TException>>, IThatDelegateThrows<TException>
public partial class ThatDelegateThrows<TException>(
ExpectationBuilder expectationBuilder,
ThatDelegate.ThrowsOption throwOptions)
: ExpectationResult<TException, ThatDelegateThrows<TException>>(expectationBuilder), IThatDelegateThrows<TException>
where TException : Exception?
{
private readonly ThatDelegate.ThrowsOption _throwOptions;

internal ThatDelegateThrows(ExpectationBuilder expectationBuilder, ThatDelegate.ThrowsOption throwOptions)
: base(expectationBuilder)
{
ExpectationBuilder = expectationBuilder;
_throwOptions = throwOptions;
}
/// <summary>
/// The throw options.
/// </summary>
public ThatDelegate.ThrowsOption ThrowOptions { get; } = throwOptions;

/// <summary>
/// The expectation builder.
/// </summary>
public ExpectationBuilder ExpectationBuilder { get; }
public ExpectationBuilder ExpectationBuilder { get; } = expectationBuilder;
}
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,13 @@ namespace aweXpect.Delegates
public aweXpect.Delegates.ThatDelegateThrows<TException> ThrowsExactly<TException>()
where TException : System.Exception { }
public aweXpect.Delegates.ThatDelegateThrows<System.Exception> ThrowsException() { }
public class ThrowsOption
{
public ThrowsOption() { }
public bool DoCheckThrow { get; }
public aweXpect.Options.TimeSpanEqualityOptions? ExecutionTimeOptions { get; set; }
public void CheckThrow(bool doCheckThrow) { }
}
public sealed class WithValue<T> : aweXpect.Delegates.ThatDelegate, aweXpect.Core.IExpectThat<aweXpect.Delegates.ThatDelegate.WithValue<T>>, aweXpect.Core.IThat<aweXpect.Delegates.ThatDelegate.WithValue<T>>
{
public WithValue(aweXpect.Core.ExpectationBuilder expectationBuilder) { }
Expand Down Expand Up @@ -488,7 +495,9 @@ namespace aweXpect.Delegates
public class ThatDelegateThrows<TException> : aweXpect.Results.ExpectationResult<TException, aweXpect.Delegates.ThatDelegateThrows<TException>>, aweXpect.Core.IExpectThat<TException>, aweXpect.Core.IThatDelegateThrows<TException>, aweXpect.Core.IThat<TException>
where TException : System.Exception?
{
public ThatDelegateThrows(aweXpect.Core.ExpectationBuilder expectationBuilder, aweXpect.Delegates.ThatDelegate.ThrowsOption throwOptions) { }
public aweXpect.Core.ExpectationBuilder ExpectationBuilder { get; }
public aweXpect.Delegates.ThatDelegate.ThrowsOption ThrowOptions { get; }
public aweXpect.Core.IThat<TException> Which { get; }
public aweXpect.Delegates.ThatDelegateThrows<TException?> OnlyIf(bool predicate) { }
public aweXpect.Results.AndOrResult<TException, aweXpect.Delegates.ThatDelegateThrows<TException>> Whose<TMember>(System.Func<TException, TMember?> memberSelector, System.Action<aweXpect.Core.IThat<TMember?>> expectations, [System.Runtime.CompilerServices.CallerArgumentExpression("memberSelector")] string doNotPopulateThisValue = "") { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,13 @@ namespace aweXpect.Delegates
public aweXpect.Delegates.ThatDelegateThrows<TException> ThrowsExactly<TException>()
where TException : System.Exception { }
public aweXpect.Delegates.ThatDelegateThrows<System.Exception> ThrowsException() { }
public class ThrowsOption
{
public ThrowsOption() { }
public bool DoCheckThrow { get; }
public aweXpect.Options.TimeSpanEqualityOptions? ExecutionTimeOptions { get; set; }
public void CheckThrow(bool doCheckThrow) { }
}
public sealed class WithValue<T> : aweXpect.Delegates.ThatDelegate, aweXpect.Core.IExpectThat<aweXpect.Delegates.ThatDelegate.WithValue<T>>, aweXpect.Core.IThat<aweXpect.Delegates.ThatDelegate.WithValue<T>>
{
public WithValue(aweXpect.Core.ExpectationBuilder expectationBuilder) { }
Expand Down Expand Up @@ -488,7 +495,9 @@ namespace aweXpect.Delegates
public class ThatDelegateThrows<TException> : aweXpect.Results.ExpectationResult<TException, aweXpect.Delegates.ThatDelegateThrows<TException>>, aweXpect.Core.IExpectThat<TException>, aweXpect.Core.IThatDelegateThrows<TException>, aweXpect.Core.IThat<TException>
where TException : System.Exception?
{
public ThatDelegateThrows(aweXpect.Core.ExpectationBuilder expectationBuilder, aweXpect.Delegates.ThatDelegate.ThrowsOption throwOptions) { }
public aweXpect.Core.ExpectationBuilder ExpectationBuilder { get; }
public aweXpect.Delegates.ThatDelegate.ThrowsOption ThrowOptions { get; }
public aweXpect.Core.IThat<TException> Which { get; }
public aweXpect.Delegates.ThatDelegateThrows<TException?> OnlyIf(bool predicate) { }
public aweXpect.Results.AndOrResult<TException, aweXpect.Delegates.ThatDelegateThrows<TException>> Whose<TMember>(System.Func<TException, TMember?> memberSelector, System.Action<aweXpect.Core.IThat<TMember?>> expectations, [System.Runtime.CompilerServices.CallerArgumentExpression("memberSelector")] string doNotPopulateThisValue = "") { }
Expand Down
Loading