Example #1
0
        public void Dispose_NullSite_Success()
        {
            var component = new SubComponent();

            component.Dispose();
            component.Dispose();
        }
Example #2
0
        public void Dispose_NullSiteContainer_Success()
        {
            var component = new SubComponent()
            {
                Site = new MockSite {
                    Container = null
                }
            };

            component.Dispose();
            component.Dispose();
        }
Example #3
0
        public void Dispose_NonNullSiteContainer_RemovesComponentFromContainer()
        {
            var component = new SubComponent()
            {
                Site = new MockSite {
                    Container = new Container()
                }
            };

            component.Dispose();
            Assert.Null(component.Site);

            component.Dispose();
        }
Example #4
0
        public void Dispose_NullSiteContainer_Success()
        {
            var site = new MockSite
            {
                Container = null
            };
            var component = new SubComponent
            {
                Site = site
            };

            component.Dispose();
            Assert.Same(site, component.Site);

            component.Dispose();
            Assert.Same(site, component.Site);
        }
Example #5
0
        public void Dispose_HasDisposedEvent_InvokesEvent()
        {
            var component = new SubComponent();

            component.Disposed += Component_Disposed;

            component.Dispose();
            Assert.True(InvokedDisposed);

            InvokedDisposed = false;
            component.Dispose();
            Assert.True(InvokedDisposed);

            component.Disposed -= Component_Disposed;
            InvokedDisposed     = false;
            component.Dispose();
            Assert.False(InvokedDisposed);
        }
Example #6
0
        public void Dispose_HasDisposedWithoutEvents_DoesNotnvokesEvent()
        {
            var component = new SubComponent();

            component.Disposed += Component_Disposed;
            component.CanRaiseEventsInternal = false;

            component.Dispose();
            Assert.False(InvokedDisposed);
        }
Example #7
0
        public void Dispose_InvokeBoolWithDisposed_CallsHandlerIfDisposing(bool disposing, int expectedCallCount)
        {
            var          component = new SubComponent();
            int          callCount = 0;
            EventHandler handler   = (sender, e) =>
            {
                Assert.Same(component, sender);
                Assert.Same(EventArgs.Empty, e);
                callCount++;
            };

            component.Disposed += handler;

            component.Dispose(disposing);
            Assert.Equal(expectedCallCount, callCount);

            component.Dispose(disposing);
            Assert.Equal(expectedCallCount * 2, callCount);

            // Remove handler.
            component.Disposed -= handler;
            component.Dispose(disposing);
            Assert.Equal(expectedCallCount * 2, callCount);
        }
Example #8
0
        public void Dispose_InvokeWithDisposed_CallsHandler()
        {
            var          component = new SubComponent();
            int          callCount = 0;
            EventHandler handler   = (sender, e) =>
            {
                Assert.Same(component, sender);
                Assert.Same(EventArgs.Empty, e);
                callCount++;
            };

            component.Disposed += handler;

            component.Dispose();
            Assert.Equal(1, callCount);

            component.Dispose();
            Assert.Equal(2, callCount);

            // Remove handler.
            component.Disposed -= handler;
            component.Dispose();
            Assert.Equal(2, callCount);
        }