You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Fact]
public async Task EventStateBaseWithoutEventTransitions_WithoutCancellation_ReturnsReturnValueOfExecuteEventStepAsync()
{
var logger = new TestLogger();
var stateTransition = new Transition("Targeted", Mock.Of<TransitionTarget>(), logger.TransitionAction, null);
var stateMock = new Mock<EventStateBase>(
"test",
logger.StateEnterAction,
logger.StateExitAction,
logger.StateCancelledAction)
{
CallBase = true,
};
stateMock.Protected()
.Setup<Task<Transition>>("ExecuteEventStepAsync", It.IsAny<CancellationToken>())
.ReturnsAsync(stateTransition);
var actual = await stateMock.Object.ExecuteAsync(CancellationToken.None);
Assert.Equal(stateTransition, actual);
Assert.Equal(">test;<test;", logger.ToString());
stateMock.Protected().Verify<Task<Transition>>("ExecuteEventStepAsync", Times.Once(), It.IsAny<CancellationToken>());
}
But if I add a call to a public method of the mocked instance, the setup is ignored and the mock will return the default value and, on verification, is reported as not having been called.
Could you please provide a short but complete repro code? It would be easier to look into this if one didn't have to guess at all the types and symbols not defined here. Thank you!
Version: 4.6.38-alpha
Project: .NET Core class library
I have this test that works just fine:
But if I add a call to a public method of the mocked instance, the setup is ignored and the mock will return the default value and, on verification, is reported as not having been called.
It happens with this test, for example:
What am I doing wrong?
The text was updated successfully, but these errors were encountered: