public void Call_ConvertCurrency_ShoulReturn_CurrencyInWords() { //Arrange var requestCurrencyModel = new RequestCurrencyModel { Name = "Muhammad Zeeshan", Currency = new decimal(123.45) }; var wordsCurrencyModel = new ResponseCurrencyModel { Name = "Muhammad Zeeshan", CurrencyInWords = "ONE HUNDRED AND TWENTY-THREE DOLLARS AND FORTY-FIVE CENTS" }; _service.ConvertToWords(Arg.Any <RequestCurrencyModel>()).Returns(wordsCurrencyModel); //Action var response = _controller.Post(requestCurrencyModel).ExecuteAsync(CancellationToken.None).Result; var result = JsonConvert.DeserializeObject <ResponseCurrencyModel>(response.Content.ReadAsStringAsync().Result); //Assert Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); Assert.AreEqual(result.Name, "Muhammad Zeeshan"); Assert.AreEqual(result.CurrencyInWords, "ONE HUNDRED AND TWENTY-THREE DOLLARS AND FORTY-FIVE CENTS"); }
public IHttpActionResult Post(RequestCurrencyModel model) { return(Ok(_numberToWordsService.ConvertToWords(model))); }