Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Delete bad test from AsyncValueTaskMethodBuilderTests #23356

Merged
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 @@ -82,36 +82,6 @@ public void Start_InvokesMoveNext()
Assert.Equal(1, invokes);
}

[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task AwaitOnCompleted_InvokesStateMachineMethods(bool awaitUnsafe)
{
AsyncValueTaskMethodBuilder<int> b = ValueTask<int>.CreateAsyncMethodBuilder();
var ignored = b.Task;

var callbackCompleted = new TaskCompletionSource<bool>();
IAsyncStateMachine foundSm = null;
var dsm = new DelegateStateMachine
{
MoveNextDelegate = () => callbackCompleted.SetResult(true),
SetStateMachineDelegate = sm => foundSm = sm
};

TaskAwaiter t = Task.CompletedTask.GetAwaiter();
if (awaitUnsafe)
{
b.AwaitUnsafeOnCompleted(ref t, ref dsm);
}
else
{
b.AwaitOnCompleted(ref t, ref dsm);
}

await callbackCompleted.Task;
Assert.Equal(dsm, foundSm);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, fixed.


[Theory]
[InlineData(1, false)]
[InlineData(2, false)]
Expand Down Expand Up @@ -214,8 +184,7 @@ private struct DelegateStateMachine : IAsyncStateMachine
internal Action MoveNextDelegate;
public void MoveNext() => MoveNextDelegate?.Invoke();

internal Action<IAsyncStateMachine> SetStateMachineDelegate;
public void SetStateMachine(IAsyncStateMachine stateMachine) => SetStateMachineDelegate?.Invoke(stateMachine);
public void SetStateMachine(IAsyncStateMachine stateMachine) { }
}
}
}