コード例 #1
0
        public void CreateCurrency_Action_Fails()
        {
            // Arrange
            var currencyDto = TestHelper.CurrencyDto();

            GenericServiceResponse <bool> fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.CurrencyService.CreateCurrency(currencyDto)).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericViewModel();

            var action = new CreateCurrency <GenericViewModel>(mockClientServicesProvider.Object)
            {
                OnComplete = model => viewModel = model
            };

            // Act
            var result = action.Invoke(currencyDto);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericViewModel));
            Assert.IsNotNull(result.Notifications);
            Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection));
            Assert.IsTrue(result.Notifications.Count() == 1);
            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.Success);
            Assert.IsInstanceOfType(result.Success, typeof(bool));
            Assert.IsFalse(result.Success);
        }
コード例 #2
0
        public async Task <ResponseBaseModel <string> > CreateCurrency([FromBody] CreateCurrency request)
        {
            var result = new BaseResponse();

            var currency = await _serviceClient.GetAsync(new QueryCurrencyMessage
                                                         { CurrencyCode = request.CurrencyCode });

            if (request.IfExistUpdateRate || currency == null)
            {
                result = await _serviceClient.ModifyAsync(new Currency
                {
                    CurrencyCode = request.CurrencyCode,
                    CurrencyRate = request.CurrencyRate
                });
            }

            return(new ResponseBaseModel <string>((ResponseCode)result.Code, null));
        }
コード例 #3
0
        public IApiResult Create(CreateCurrency operation)
        {
            var result = operation.ExecuteAsync().Result;

            if (result is ValidationsOutput)
            {
                return(new ApiResult <List <ValidationItem> >()
                {
                    Data = ((ValidationsOutput)result).Errors
                });
            }
            else
            {
                return(new ApiResult <object>()
                {
                    Status = ApiResult <object> .ApiStatus.Success
                });
            }
        }