Beispiel #1
0
        private async Task <AuthorizationResult> AcquireAuthCodeAsync(
            string redirectUri       = TestRedirectUri,
            string requestUri        = TestAuthorizationRequestUri,
            string responseUriString = TestAuthorizationResponseUri)
        {
            // Arrange
            var    requestContext = new RequestContext(TestCommon.CreateDefaultServiceBundle(), Guid.NewGuid());
            var    responseUri    = new Uri(responseUriString);
            IWebUI webUI          = new DefaultOsBrowserWebUi(_platformProxy, _logger, _tcpInterceptor);

            _tcpInterceptor.ListenToSingleRequestAndRespondAsync(
                TestPort,
                Arg.Any <Func <Uri, string> >(),
                CancellationToken.None)
            .Returns(Task.FromResult(responseUri));

            // Act
            AuthorizationResult authorizationResult = await webUI.AcquireAuthorizationAsync(
                new Uri(requestUri),
                new Uri(redirectUri),
                requestContext,
                CancellationToken.None).ConfigureAwait(false);

            // Assert that we opened the browser
            await _platformProxy.Received(1).StartDefaultOsBrowserAsync(requestUri)
            .ConfigureAwait(false);

            return(authorizationResult);
        }