public void ThrowsAnExceptionWhenApiReturnsNonZero()
        {
            exceptionPolicy.Setup(o => o.Create(ERROR_INVALID_HANDLE)).Returns(new TestException());

            api.Setup(o => o.RasGetConnectStatus(handle, ref It.Ref <RASCONNSTATUS> .IsAny)).Returns(
                new RasGetConnectStatusCallback((IntPtr h, ref RASCONNSTATUS rasConnStatus) => ERROR_INVALID_HANDLE));

            var target = new RasGetConnectStatusService(api.Object, structFactory.Object, ipAddressConverter.Object, exceptionPolicy.Object, deviceTypeFactory.Object);

            Assert.Throws <TestException>(() => target.GetConnectionStatus(connection.Object));
        }
        public void ThrowsAnExceptionWhenHandleIsNull()
        {
            var api                = new Mock <IRasApi32>();
            var structFactory      = new Mock <IStructFactory>();
            var ipAddressConverter = new Mock <IIPAddressConverter>();
            var exceptionPolicy    = new Mock <IExceptionPolicy>();
            var deviceTypeFactory  = new Mock <IDeviceTypeFactory>();

            var target = new RasGetConnectStatusService(api.Object, structFactory.Object, ipAddressConverter.Object, exceptionPolicy.Object, deviceTypeFactory.Object);

            Assert.Throws <ArgumentNullException>(() => target.GetConnectionStatus(null));
        }
        public void ErrorCodeIsSetWhenValueIsNonZero()
        {
            api.Setup(o => o.RasGetConnectStatus(handle, ref It.Ref <RASCONNSTATUS> .IsAny)).Returns(new RasGetConnectStatusCallback(
                                                                                                         (IntPtr h, ref RASCONNSTATUS rasConnStatus) =>
            {
                rasConnStatus.dwError = 1;
                return(SUCCESS);
            }));

            var target = new RasGetConnectStatusService(api.Object, structFactory.Object, ipAddressConverter.Object, exceptionPolicy.Object, deviceTypeFactory.Object);
            var result = target.GetConnectionStatus(connection.Object);

            Assert.AreEqual(1, result.ErrorCode);
        }
        public void ThrowsAnExceptionWhenHandleIsNull()
        {
            var target = new RasGetConnectStatusService(api.Object, structFactory.Object, ipAddressConverter.Object, exceptionPolicy.Object, deviceTypeFactory.Object);

            Assert.Throws <ArgumentNullException>(() => target.GetConnectionStatus(null));
        }