コード例 #1
0
        /// <summary>
        /// Validate currency error response
        /// </summary>
        /// <param name="expectedErrorMessage">The expected error message</param>
        /// <returns></returns>
        private async Task ValidateCurrencyErrorResponseAsync(HttpStatusCode code, string expectedErrorMessage)
        {
            CurrencyErrorResponse currencyErrorResponse =
                await _currencyAutomatedTestHelper.GetErrorModelsResults <CurrencyErrorResponse>(code);

            currencyErrorResponse.ErrorMessages.Count.Should().Be(1);
            currencyErrorResponse.ErrorMessages[0].Should().Be(expectedErrorMessage);
        }
コード例 #2
0
        private void CheckErrorMessageResponse <TObjectResult>(Func <Task <IEnumerable <CurrencyResultResponse> > > errorAction, CurrencyErrorResponse errorModel = null)
            where TObjectResult : ObjectResult
        {
            _currencyServiceMock.Setup(c => c.GetCurrencyResultsAsync(It.IsAny <CurrencyCollectionRequest>()))
            .Returns(errorAction);

            var result = _currencyController.Get(_model).GetAwaiter().GetResult();

            result.Should().BeOfType <TObjectResult>();
            var errorResponse = result as TObjectResult;

            _currencyServiceMock.Verify(c => c.GetCurrencyResultsAsync(It.IsAny <CurrencyCollectionRequest>()), Times.Once);

            errorResponse.Value.As <CurrencyErrorResponse>().Should().NotBeNull();
            errorResponse.Value.As <CurrencyErrorResponse>().Should().BeEquivalentTo(errorModel ?? _errorModel);
        }