Ejemplo n.º 1
0
        public void ReturnsNotSupportedExceptionWhenErrorIsInvalidSize()
        {
            var target = new DefaultExceptionPolicy(rasGetErrorString.Object);
            var result = target.Create(ERROR_INVALID_SIZE);

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

            Assert.IsInstanceOf <IPSecException>(result);
            StringAssert.Contains("IKE", result.Message);
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 public void ThrowsAnExceptionWhenGetErrorStringIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => _ = new DefaultExceptionPolicy(null));
 }