public void CommitAsync_ShouldRaiseInvalidOperationException_ForCommittedTransaction() { using (var target = new SimulatedFooTransaction()) { // Arrange. target.BeginAsync().Wait(); target.CommitAsync().Wait(); // Act. var action = new Action(() => { target.CommitAsync().Wait(); }); // Assert. action.Should().Throw <InvalidOperationException>($"because {nameof(target)} is committed"); } }
public void FunctionalLifeSpanTest_ShouldProduceDesiredResults_ForAsynchronousInvocation() { // Arrange. var target = (DataAccessTransaction)null; using (target = new SimulatedFooTransaction()) { // Assert. target.State.Should().Be(DataAccessTransactionState.Ready); // Act. target.BeginAsync().Wait(); // Assert. target.State.Should().Be(DataAccessTransactionState.InProgress); // Act. target.CommitAsync().Wait(); // Assert. target.State.Should().Be(DataAccessTransactionState.Committed); } // Assert. target.State.Should().Be(DataAccessTransactionState.Unspecified); // Act. var action = new Action(() => { target.BeginAsync().Wait(); }); // Assert. action.Should().Throw <InvalidOperationException>($"because {nameof(target)} is disposed"); using (target = new SimulatedFooTransaction()) { // Assert. target.State.Should().Be(DataAccessTransactionState.Ready); // Act. target.BeginAsync().Wait(); // Assert. target.State.Should().Be(DataAccessTransactionState.InProgress); // Act. target.RejectAsync().Wait(); // Assert. target.State.Should().Be(DataAccessTransactionState.Rejected); } }
public void CommitAsync_ShouldRaiseInvalidOperationException_ForReadyStateTransaction() { using (var target = new SimulatedFooTransaction()) { // Act. var action = new Action(() => { target.CommitAsync().Wait(); }); // Assert. action.Should().Throw <InvalidOperationException>($"because {nameof(target)} has not yet begun"); } }