Closed donaldgray closed 1 year ago
Hi @donaldgray,
I wasn't sure from the top of my head, it's been a while since I worked on this project 🙂
I don't think there is any other way at the moment besides the workaround you posted.
But it shouldn't be difficult to either make the ApiStub.state
value public so that you can check it, or create a TryStart()
variant as you suggested.
I'll try to get around to implement one of these improvements in the coming days.
@donaldgray I released version 2.8.3, which includes the EnsureStarted()
method: http://markvincze.github.io/Stubbery/api/Stubbery.ApiStub.html#Stubbery_ApiStub_EnsureStarted, can you check if this solves your scenario?
@markvincze - tested and it's working as expected, thank you!
Is it possible to check the ApiStub state, prior to starting? I have an extension method that handles this but it feels a little rough:
but I would much prefer if it was possible to safely start (
apiStub.TryStart()
) or have some way to check the internalApiStubState
value - am I missing something?The reason I'm looking for this is that it will simplify my xunit test setup as I use a
IClassFixture<ApiStub>
to control the lifecycle of theApiStub
but I need to call.Start()
when on first run.