Dispose() public method

public Dispose ( ) : void
return void
        public virtual void ShouldRaiseFinishedEventDuringDecoratorDispose()
        {
            var config = new UnitOfWorkConfig(string.Empty, IsolationLevel.ReadCommitted, Require.New);
            var sessionBuilder = new Lazy<IDataSession>(() => session, false);
            var policy = new ImmediateTerminationPolicy();

            var context = new DataContext(config, sessionBuilder, policy);
            var contextDecorator = new DataContextSupervisor.DataContextDecorator(context, new List<DataContextSupervisor.DataContextDecorator>());

            Awaken(contextDecorator);

            EventHandler<FinishedEventArgs> eventHandler = (sender, e) => { throw new InstanceNotFoundException(); };
            ((IDataContext)contextDecorator).Finished += eventHandler;

            try
            {
                contextDecorator.Dispose();
            }
            catch (InstanceNotFoundException)
            {
            }

            session.Received(1).Dispose();

            session.ClearReceivedCalls();

            context = new DataContext(config, sessionBuilder, policy);
            contextDecorator = new DataContextSupervisor.DataContextDecorator(context, new List<DataContextSupervisor.DataContextDecorator>());

            Awaken(contextDecorator);

            eventHandler = (s, e) => { throw new InstanceNotFoundException(); };
            ((IDataContext)contextDecorator).Finished += eventHandler;
            ((IDataContext)contextDecorator).Finished -= eventHandler;
            contextDecorator.Dispose();
            session.Received(1).Dispose();
        }