public void Setup()
 {
     this.converter  = new Mock <ICurrencyConverterService>();
     this.controller = new TrainlineFXController(this.converter.Object);
     this.response   = new ResponseFX()
     {
         Amount = 2.5, TargetCurrency = "EUR"
     };
 }
Exemplo n.º 2
0
        public IActionResult Get(RequestFX requestFx)
        {
            ResponseFX responseFx = currencyConverterService.ConvertCurrency(requestFx);

            if (responseFx is null)
            {
                return(this.BadRequest());
            }

            return(this.Ok(responseFx));
        }
Exemplo n.º 3
0
        public void WhenCallingCurrencyConverterWithValidParametersReturnSuccessful()
        {
            var request = new RequestFX()
            {
                Amount         = "1.00",
                SourceCurrency = "GBP",
                TargetCurrency = "EUR"
            };

            this.exchangeRates.Setup(e => e.RetrieveLatestJsonRates(It.IsAny <string>())).ReturnsAsync(this.rates);
            var responseFx = new ResponseFX()
            {
                Amount = 1.16, TargetCurrency = "EUR"
            };

            var result = this.currencyConverter.ConvertCurrency(request);

            Assert.IsNotNull(result);
            Assert.AreEqual(responseFx.Amount, result.Amount);
            Assert.AreEqual(responseFx.TargetCurrency, result.TargetCurrency);
        }