public void GivenDisposedPropertyGridViewWithDataSet_WhenRefreshRequiredEventRaised_ThenRefreshNotTriggered()
        {
            // Given
            var dataObject = new object();

            var mockRepository   = new MockRepository();
            var objectProperties = mockRepository.Stub <IObjectProperties>();
            var propertyResolver = mockRepository.StrictMock <IPropertyResolver>();

            propertyResolver.Expect(prs => prs.GetObjectProperties(dataObject)).Return(new DynamicPropertyBag(objectProperties));
            mockRepository.ReplayAll();

            var propertyGridView = new TestGuiPropertyGridView(propertyResolver)
            {
                Data = dataObject
            };

            propertyGridView.Dispose();

            // When
            objectProperties.Raise(p => p.RefreshRequired += null,
                                   objectProperties,
                                   EventArgs.Empty);

            // Then
            Assert.AreEqual(0, propertyGridView.RefreshCalled);
            mockRepository.VerifyAll();
        }
        public void GivenPropertyGridViewWithDisposableDataSet_WhenDisposing_ThenObjectPropertiesCorrectlyDisposed()
        {
            // Given
            var    mockRepository       = new MockRepository();
            var    dataObject           = new object();
            object dataObjectProperties = mockRepository.StrictMultiMock(typeof(IDisposable), typeof(IObjectProperties));

            dataObjectProperties.Expect(d => ((IDisposable)d).Dispose());
            dataObjectProperties.Expect(d => ((IObjectProperties)d).RefreshRequired += null).IgnoreArguments();
            dataObjectProperties.Expect(d => ((IObjectProperties)d).RefreshRequired -= null).IgnoreArguments();
            dataObjectProperties.Stub(d => ((IObjectProperties)d).Data).Return(dataObject);

            var propertyResolver = mockRepository.StrictMock <IPropertyResolver>();

            propertyResolver.Expect(prs => prs.GetObjectProperties(dataObject)).Return(new DynamicPropertyBag(dataObjectProperties));
            mockRepository.ReplayAll();

            var propertyGridView = new TestGuiPropertyGridView(propertyResolver)
            {
                Data = dataObject
            };

            // When
            propertyGridView.Dispose();

            // Then
            mockRepository.VerifyAll();
        }