public async Task OpenAndAbort() { var o = new TestCommunicationObject(); await o.OpenAsync(); await o.AbortAsync(); o.State .Should().Be(CommunicationState.Closed); o.Record .Should().Equal(new string[] { "OnOpeningAsync", "Event_Opening", "OnOpenAsync", "OnOpenedAsync", "Event_Opened", "OnClosingAsync", "Event_Closing", "OnAbortAsync", "OnClosedAsync", "Event_Closed" }); }
public async Task OpenAndCloseOnOpen() { var o = new TestCommunicationObject { IsInterceptingTest = true }; o.DoOn("OnOpenAsync", async co => await co.CloseAsync()); await o.OpenAsync(); o.State .Should().Be(CommunicationState.Closed); o.Record .Should().Equal(new string[] { "OnOpeningAsync", "Event_Opening", "OnOpenAsync", "OnClosingAsync", "Event_Closing", "OnAbortAsync", "OnClosedAsync", "Event_Closed", "OnOpenedAsync" }); }
public async Task OpenAndOpen() { var o = new TestCommunicationObject(); await o.OpenAsync(); // Calling open is only allowed on a fresh object await o.Invoking(x => x.OpenAsync()) .Should().ThrowAsync <InvalidOperationException>(); }