コード例 #1
0
        public void GetAmountWord_ExpectedResult(Double input, string expectResult)
        {
            var chequeService = new ChequeService();
            var result        = chequeService.GetAmountWord(input);

            Assert.IsTrue(result == expectResult, $"incorrect amount word, expect {expectResult} but {result}");
        }
コード例 #2
0
        // Post: api/Cheque/create
        public HttpResponseMessage Post([FromBody] ChequeRequest request)
        {
            var chequeService = new ChequeService();
            var message       = string.Empty;
            var isValid       = chequeService.IsValidCheque(request, out message);

            if (isValid)
            {
                var amountWord = chequeService.GetAmountWord(request.Amount);
                return(ToJson(new Cheque()
                {
                    ChequeDate = request.ChequeDate, Amount = request.Amount, Payee = request.Payee, AmountWord = amountWord
                }));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, message));
            }
        }