コード例 #1
0
        public ApiResult <NumberTransformResponse> Transform(NumberTransformRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException();
            }

            try
            {
                return(new ApiResult <NumberTransformResponse>()
                {
                    IsSuccess = true,
                    Result = new NumberTransformResponse()
                    {
                        Text = _humanizer.Transform(request.Number),
                        Number = request.Number,
                        Name = request.Name
                    }
                });
            }
            catch (Exception e)
            {
                return(new ApiResult <NumberTransformResponse>()
                {
                    IsSuccess = false,
                    ErrorMessage = e.Message,
                    Result = null
                });
            }
        }
コード例 #2
0
 public void NumberHumanizerOneDigit(string input, string output)
 {
     Assert.AreEqual(output, _humanizer.Transform(input));
 }
コード例 #3
0
 public void NumberHumanizer_ThrowsException_WhenNumberIsNotValid(string input)
 {
     Assert.Catch <ArgumentException>(() => _humanizer.Transform(input));
 }