public void Construct()
        {
            var exception = new DummyException("This is a dummy");

            var resourceResult = new ExceptionResourceResult(exception);

            Assert.Equal(exception.ToString(), resourceResult.Message);
        }
Esempio n. 2
0
        public void ReducePolicyOnError()
        {
            var ex = new DummyException("I am a problem.");
            Policy.RequestMetadataMock.Setup(r => r.ResponseContentType).Throws(ex);

            Assert.Equal(RuntimePolicy.Off, Policy.Execute(Policy.ContextMock.Object));
            Policy.LoggerMock.Verify(l => l.Warn(It.IsAny<string>(), ex, It.IsAny<object[]>()), Times.Once());
        }
Esempio n. 3
0
        public void CallAbstractInfoWithException()
        {
            var loggerMock = new Mock<LoggerBase>();
            var exception = new DummyException();

            loggerMock.Object.Info("message Format", exception, new object[] { "One", 2 });

            loggerMock.Verify(l => l.Info(It.IsAny<string>(), exception), Times.Once());
        }
        public void ConstructWithMessageAndInnerException()
        {
            var message = "Testing";
            var innerException = new DummyException();
            var exception = new GlimpseException(message, innerException);

            Assert.Equal(message, exception.Message);
            Assert.Equal(innerException, exception.InnerException);
        }
Esempio n. 5
0
        public void ReduceRuntimePolicyOnException()
        {
            var exception = new DummyException("Houston, we have a problem");

            Policy.RequestMetadataMock.Setup(r => r.RequestUri).Throws(exception);

            Assert.Equal(RuntimePolicy.Off, Policy.Execute(Policy.ContextMock.Object));

            Policy.LoggerMock.Verify(l => l.Warn(It.IsAny<string>(), exception, It.IsAny<object[]>()), Times.Once());
        }
        public void Execute()
        {
            var providerMock = new Mock<IFrameworkProvider>();
            var contextMock = new Mock<IResourceResultContext>();
            contextMock.Setup(c => c.FrameworkProvider).Returns(providerMock.Object);

            var exception = new DummyException("This is a dummy");

            var resourceResult = new ExceptionResourceResult(exception);

            resourceResult.Execute(contextMock.Object);

            providerMock.Verify(p=>p.WriteHttpResponse(exception.ToString()));
            providerMock.Verify(p=>p.SetHttpResponseStatusCode(500));
        }