public void DoesNotThrowAnExceptionWhenInitializedMoreThanOnce()
        {
            var rasEnumConnections = new Mock <IRasEnumConnections>();

            var target = new RasConnectionNotificationCallbackHandler(rasEnumConnections.Object);

            target.Initialize();
            Assert.DoesNotThrow(() => target.Initialize());

            rasEnumConnections.Verify(o => o.EnumerateConnections(), Times.Once);
        }
        public void ExecutesTheCallbackWhenAConnectionHasConnected()
        {
            var executed           = false;
            var connection         = new Mock <RasConnection>();
            var registeredCallback = new Mock <IRegisteredCallback>();

            var rasEnumConnections = new Mock <IRasEnumConnections>();

            rasEnumConnections.SetupSequence(o => o.EnumerateConnections())
            .Returns(new RasConnection[0])
            .Returns(new[] { connection.Object });

            var target = new RasConnectionNotificationCallbackHandler(rasEnumConnections.Object);

            target.Initialize();

            target.OnCallback(new RasConnectionNotificationStateObject
            {
                Callback = (e) =>
                {
                    executed = true;
                },
                NotificationType   = RASCN.Connection,
                RegisteredCallback = registeredCallback.Object
            }, false);

            Assert.True(executed);
            rasEnumConnections.Verify(o => o.EnumerateConnections(), Times.Exactly(2));
        }
        public void MustInitializeTheCurrentState()
        {
            var rasEnumConnections = new Mock <IRasEnumConnections>();

            var target = new RasConnectionNotificationCallbackHandler(rasEnumConnections.Object);

            target.Initialize();

            rasEnumConnections.Verify(o => o.EnumerateConnections(), Times.Once);
        }