public void Reject_ShouldRaiseInvalidOperationException_ForRejectedTransaction() { using (var target = new SimulatedFooTransaction()) { // Arrange. target.Begin(); target.Reject(); // Act. var action = new Action(() => { target.Reject(); }); // Assert. action.Should().Throw <InvalidOperationException>($"because {nameof(target)} is rejected"); } }
public void FunctionalLifeSpanTest_ShouldProduceDesiredResults_ForSynchronousInvocation() { // Arrange. var target = (DataAccessTransaction)null; using (target = new SimulatedFooTransaction()) { // Assert. target.State.Should().Be(DataAccessTransactionState.Ready); // Act. target.Begin(); // Assert. target.State.Should().Be(DataAccessTransactionState.InProgress); // Act. target.Commit(); // Assert. target.State.Should().Be(DataAccessTransactionState.Committed); } // Assert. target.State.Should().Be(DataAccessTransactionState.Unspecified); // Act. var action = new Action(() => { target.Begin(); }); // Assert. action.Should().Throw <InvalidOperationException>($"because {nameof(target)} is disposed"); using (target = new SimulatedFooTransaction()) { // Assert. target.State.Should().Be(DataAccessTransactionState.Ready); // Act. target.Begin(); // Assert. target.State.Should().Be(DataAccessTransactionState.InProgress); // Act. target.Reject(); // Assert. target.State.Should().Be(DataAccessTransactionState.Rejected); } }
public void Reject_ShouldRaiseInvalidOperationException_ForReadyStateTransaction() { using (var target = new SimulatedFooTransaction()) { // Act. var action = new Action(() => { target.Reject(); }); // Assert. action.Should().Throw <InvalidOperationException>($"because {nameof(target)} has not yet begun"); } }