상속: ITerminationPolicy
        public virtual void ShouldAggregateExceptionsOnDispose()
        {
            var session1 = Substitute.For<IDataSession>();
            var session2 = Substitute.For<IDataSession>();
            var session3 = Substitute.For<IDataSession>();

            session1.When(s => s.Dispose()).Do(s => { throw new Exception("session1"); });
            session3.When(s => s.Dispose()).Do(s => { throw new Exception("session3"); });

            var policy = new DeferredTerminationPolicy();

            policy.Terminate(session1, true);
            policy.Terminate(session2, true);
            policy.Terminate(session3, true);

            try
            {
                ((IDisposable)policy).Dispose();
            }
            catch (AggregateException aggregateException)
            {
                aggregateException.Message.Should().Be("session1");
                aggregateException.InnerExceptions.Any(e => e.Message == "session1").Should().Be.True();
                aggregateException.InnerExceptions.Any(e => e.Message == "session2").Should().Be.False();
                aggregateException.InnerExceptions.Any(e => e.Message == "session3").Should().Be.True();
                aggregateException.InnerExceptions.Count().Should().Be(2);
            }

            session1.Received(1).Dispose();
            session2.Received(1).Dispose();
            session3.Received(1).Dispose();
        }
        public virtual void ShouldTerminateSessionImmediatelyIfPolicyDisposed()
        {
            var session1 = Substitute.For<IDataSession>();

            var policy = new DeferredTerminationPolicy();

            ((IDisposable)policy).Dispose();

            policy.Terminate(session1, true);
            session1.Received(1).Dispose();
        }
        public virtual void ShouldPostponeSessionTermination()
        {
            var session1 = Substitute.For<IDataSession>();
            var session2 = Substitute.For<IDataSession>();

            var policy = new DeferredTerminationPolicy();

            policy.Terminate(session1, true);
            session1.Received(0).Dispose();
            policy.Terminate(session2, true);
            session2.Received(0).Dispose();

            ((IDisposable)policy).Dispose();
            session1.Received(1).Dispose();
            session2.Received(1).Dispose();
        }