public async Task RateInteractorGetRateAsyncTest(string curFrom, string curTo, string input) { var expectedValue = 500M; _isoCodeHelperMoq.Setup(i => i.GetIsoCode(curFrom)) .Returns(10); _isoCodeHelperMoq.Setup(i => i.GetIsoCode(curTo)) .Returns(20); _requesterMoq.Setup(r => r.GetRate(10, 20)) .Returns(Task.FromResult(5M)); var actualValue = await _rateInteractor.GetRate(curFrom, curTo, input); Assert.AreEqual(expectedValue, actualValue); _requesterMoq.Verify(r => r.GetRate(10, 20), Times.Once); _isoCodeHelperMoq.Verify(i => i.GetIsoCode(curFrom), Times.Once); _isoCodeHelperMoq.Verify(i => i.GetIsoCode(curTo), Times.Once); }
public Task <string> GetRate(string curFrom, string curTo, string input) { var rate = _interactor.GetRate(curFrom, curTo, input).Result; string result = Regex.Match($"{rate}", _currencyPattern).Value; if (string.IsNullOrEmpty(result)) { return(Task.FromResult("0")); } return(Task.FromResult(result)); }