public void DisposeMustCleanUpSubscriptions()
        {
            var handle = new IntPtr(1);

            var connection = new Mock <IRasConnection>();

            connection.Setup(o => o.Handle).Returns(handle);

            var registeredCallback = new Mock <IRegisteredCallback>();

            var api             = new Mock <IRasApi32>();
            var callbackHandler = new Mock <IRasConnectionNotificationCallbackHandler>();
            var exceptionPolicy = new Mock <IExceptionPolicy>();

            var callbackFactory = new Mock <IRegisteredCallbackFactory>();

            callbackFactory.Setup(o => o.Create(It.IsAny <WaitOrTimerCallback>(), It.IsAny <object>())).Returns(registeredCallback.Object);

            var target = new RasConnectionNotificationService(api.Object, callbackHandler.Object, exceptionPolicy.Object, callbackFactory.Object);

            target.Subscribe(new RasNotificationContext
            {
                Connection             = connection.Object,
                OnDisconnectedCallback = e => { }
            });

            target.Dispose();

            registeredCallback.Verify(o => o.Dispose(), Times.Exactly(2));
        }
        public void ThrowsAnExceptionWhenResetAfterDispose()
        {
            var api             = new Mock <IRasApi32>();
            var callbackHandler = new Mock <IRasConnectionNotificationCallbackHandler>();
            var exceptionPolicy = new Mock <IExceptionPolicy>();
            var callbackFactory = new Mock <IRegisteredCallbackFactory>();

            var target = new RasConnectionNotificationService(api.Object, callbackHandler.Object, exceptionPolicy.Object, callbackFactory.Object);

            target.Dispose();

            Assert.Throws <ObjectDisposedException>(() => target.Reset());
        }