public void ReturnsNotSupportedExceptionWhenErrorIsInvalidSize()
        {
            var target = new DefaultExceptionPolicy(rasGetErrorString.Object);
            var result = target.Create(ERROR_INVALID_SIZE);

            Assert.IsInstanceOf <OperatingSystemNotSupportedException>(result);
        }
        public void ReturnsAnIPSecExceptionForIkeCredentialsUnacceptableErrorCode()
        {
            var target = new DefaultExceptionPolicy(rasGetErrorString.Object);
            var result = target.Create(13801);

            Assert.IsInstanceOf <IPSecException>(result);
            StringAssert.Contains("IKE", result.Message);
        }
        public void ReturnsAWin32ExceptionWhenTheMessageIsNotFoundInRas()
        {
            var target = new DefaultExceptionPolicy(rasGetErrorString.Object);
            var result = target.Create(int.MinValue);

            rasGetErrorString.Verify(o => o.GetErrorString(int.MinValue), Times.Never);
            Assert.IsInstanceOf <Win32Exception>(result);
        }
        public void ThrowsAnExceptionWhenErrorIsSuccess()
        {
            var rasGetErrorString = new Mock <IRasGetErrorString>();

            var target = new DefaultExceptionPolicy(rasGetErrorString.Object);

            Assert.Throws <ArgumentException>(() => target.Create(SUCCESS));
        }
        public void ReturnsAnUnknownErrorForRasExceptionsWithNoMessage()
        {
            rasGetErrorString.Setup(o => o.GetErrorString(600)).Returns("").Verifiable();

            var target = new DefaultExceptionPolicy(rasGetErrorString.Object);
            var result = target.Create(600) as RasException;

            Assert.IsNotNull(result);
            Assert.AreEqual("Unknown error.", result.Message);
        }
        public void ReturnsARasExceptionWhenTheMessageIsFound()
        {
            rasGetErrorString.Setup(o => o.GetErrorString(ERROR_BUFFER_TOO_SMALL)).Returns("The buffer is too small.")
            .Verifiable();

            var target = new DefaultExceptionPolicy(rasGetErrorString.Object);
            var result = target.Create(ERROR_BUFFER_TOO_SMALL);

            rasGetErrorString.Verify();
            Assert.IsInstanceOf <RasException>(result);
        }