Example #1
0
        public async Task ShouldCreatePexaWorkspaceResponse()
        {
            using (var _httpClient = new PEXAMockHttpClient(A.Fake <PEXAMockClientHandler>(opt => opt.CallsBaseMethods())))
            {
                var _iPEXAService = new PEXAService(_httpClient, _config);

                var response = await _iPEXAService.Handle <WorkspaceCreationResponse>(
                    new WorkspaceCreationRequestCommand(new WorkspaceCreationRequest(), "testBearerToken"), CancellationToken.None).ConfigureAwait(true);

                Assert.Equal("PEXA190167645", response.WorkspaceId);
                Assert.Equal("In Preparation", response.WorkspaceStatus);
            }
        }
Example #2
0
        public async Task ShouldCaptureExceptionResponse()
        {
            try
            {
                using (var _httpClient = new PEXAMockHttpClient(A.Fake <PEXAMockClientHandler>(opt => opt.CallsBaseMethods())))
                {
                    var _iPEXAService = new PEXAService(_httpClient, _config);

                    _httpClient.MockHandler.ReturnException = true;
                    var response = await _iPEXAService.Handle <WorkspaceCreationResponse>(
                        new WorkspaceCreationRequestCommand(new WorkspaceCreationRequest(), "testBearerToken"), CancellationToken.None).ConfigureAwait(true);
                }
            }
            catch (PEXAException ex)
            {
                var exceptionResponse = ex.ExceptionResponse;
                Assert.Equal("400001", exceptionResponse.ExceptionList.ElementAt(0).Code);
                Assert.Equal("The message has failed schema validation", exceptionResponse.ExceptionList.ElementAt(0).Message);
                Assert.Equal("OB1409.002", exceptionResponse.ExceptionList.ElementAt(1).Code);
                Assert.Equal("The workgroup cannot be found", exceptionResponse.ExceptionList.ElementAt(1).Message);
            }
        }