public void DesignerSerializationManager_OnSessionDisposed_InvokeWithSerializationComplete_CallsHandler(EventArgs eventArgs)
        {
            var          manager   = new SubDesignerSerializationManager();
            int          callCount = 0;
            EventHandler handler   = (sender, e) =>
            {
                Assert.Same(manager, sender);
                Assert.Same(eventArgs, e);
                callCount++;
            };
            IDisposable session = manager.CreateSession();

            manager.SerializationComplete += handler;
            manager.OnSessionDisposed(eventArgs);
            Assert.Equal(1, callCount);
            session.Dispose();

            // Call again.
            session = manager.CreateSession();
            session.Dispose();
            Assert.Equal(1, callCount);

            // Remove handler.
            session = manager.CreateSession();
            manager.SerializationComplete += handler;
            manager.SerializationComplete -= handler;
            session.Dispose();
            Assert.Equal(1, callCount);
        }
        public void DesignerSerializationManager_Context_GetWithSession_ReturnsExpected()
        {
            var          manager = new SubDesignerSerializationManager();
            IDisposable  session = manager.CreateSession();
            ContextStack context = manager.Context;

            Assert.Null(context.Current);
            Assert.Same(context, manager.Context);
        }
        public void DesignerSerializationManager_Context_GetNoSessionAfterGetting_ThrowsInvalidOperationException()
        {
            var          manager = new SubDesignerSerializationManager();
            IDisposable  session = manager.CreateSession();
            ContextStack context = manager.Context;

            Assert.NotNull(context);
            Assert.Same(context, manager.Context);
            session.Dispose();
            Assert.Throws <InvalidOperationException>(() => manager.Context);
        }