Esempio n. 1
0
        public async Task ExceptionFilterAttribute_ExceptionTestAsync()
        {
            var mockKey = "29d342d1-8d08-44fc-a8bc-2ac3e25af903";

            Environment.SetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY", mockKey);

            var exceptionFilter = new ExceptionFilterAttribute();

            var exceptionContext = new FunctionExceptionContext(
                functionInstanceId: Guid.NewGuid(),
                functionName: "FunctionMock",
                logger: _loggerMock.Object,
                exceptionDispatchInfo: ExceptionDispatchInfo.Capture(new Exception("MockException")),
                properties: new Dictionary <string, object>());

            await exceptionFilter.OnExceptionAsync(exceptionContext, new CancellationToken());

            Assert.NotNull(exceptionFilter);
        }