Exemple #1
0
        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");
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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");
            }
        }