예제 #1
0
            public void DoesNotHideThrownExceptions()
            {
                bool caughtException = false;

                #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
                apiClient
                .Send(Arg.Any <IRequest>())
                .Returns(async x => throw new WebException());
                #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously

                statusApi.IsAvailable()
                .Catch((WebException exception) =>
                {
                    caughtException = true;
                    return(Observable.Return(Unit.Default));
                }).Wait();

                caughtException.Should().BeTrue();
            }
예제 #2
0
            public async Task DoesNotHideThrownExceptions()
            {
                bool caughtException = false;

#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
                apiClient
                .Send(Arg.Any <IRequest>())
                .Returns(async x => throw new WebException());
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously

                try
                {
                    await statusApi.IsAvailable();
                }
                catch
                {
                    caughtException = true;
                }

                caughtException.Should().BeTrue();
            }