Пример #1
0
        public async Task ExecuteOperationAsync_UnexpectedExceptionIsWrappedInFatalClientException()
        {
            var mockPipeline = new Mock <IPipeline>(MockBehavior.Strict);

            // some unexpected exception
            var innerException = new UnauthorizedAccessException();

            mockPipeline
            .Setup(h => h.ProcessAsync(
                       It.IsAny <PipelineContext <BasicTestEntity> >(),
                       It.IsAny <ILogger>(),
                       It.IsAny <CancellationToken>()))
            .Callback((PipelineContext <BasicTestEntity> context, ILogger log, CancellationToken cancellationToken) => {
                throw innerException;
            })
            .Returns(Task.CompletedTask);

            this.mockPipelineFactory
            .Setup(h => h.GetPipeline(
                       It.IsAny <PipelineContext <BasicTestEntity> >()))
            .Returns(mockPipeline.Object);

            var getContext = new GetContext <BasicTestEntity>(EndpointName.Tests, null);

            try
            {
                await this.apiService.ExecuteOperationAsync(getContext, default).ConfigureAwait(false);

                Assert.Fail($"Expected {nameof(FatalClientException)} to be thrown.");
            }
            catch (FatalClientException e)
            {
                Assert.IsInstanceOfType(e.InnerException, innerException.GetType());
            }
        }
Пример #2
0
        public void Erreur_UnauthorizedAccessException_Bien_Traite()
        {
            UnauthorizedAccessException ex = new UnauthorizedAccessException("UnauthorizedAccessException");

            GestionErreur.GerrerErreur(ex);
            msbs.Verify(mm => mm.ShowError(AxLanguage.Languages.REAplan_Erreur_Admin + "\n" + AxLanguage.Languages.REAplan_Erreur_Call + "\n" + AxLanguage.Languages.REAplan_Erreur_NumeroTelephone));
            log.Verify(ll => ll.Error(ex.GetType().Name + " | " + ex.Message + " |" + ex.StackTrace));
        }