public async Task ListRates_CallsListRatesMethodFromServicesLayer_WichReturnsAListWithOnItem() { Mock <IRateBusiness> business = new Mock <IRateBusiness>(); business.Setup(m => m.ListRates()).Returns(Task.FromResult(oneCurrencyConvertion)); IRateService sut = new RateService(business.Object, commonFakes.Mapper); List <CurrencyConvertion> result = await sut.ListRates(); Assert.AreEqual(oneCurrencyConvertion.Count, result.Count); }
public async Task ListRates_WithoutParameters_ReturnsARateList() { Mock <IRateBusiness> business = new Mock <IRateBusiness>(); business.Setup(m => m.ListRates()).Returns(Task.FromResult(oneCurrencyConvertion)); IRateService sut = new RateService(business.Object, commonFakes.Mapper); List <CurrencyConvertion> result = await sut.ListRates(); Assert.IsTrue(result is List <CurrencyConvertion>, "result is not a 'CurrencyConvertion list'"); }
public async Task ListRates_WithoutParameters_InvokesListRatesMethodFromBusinessLayer() { Mock <IRateBusiness> business = new Mock <IRateBusiness>(); business.Setup(m => m.ListRates()).Returns(Task.FromResult(oneCurrencyConvertion)); IRateService sut = new RateService(business.Object, commonFakes.Mapper); List <CurrencyConvertion> result = await sut.ListRates(); business.Verify(m => m.ListRates(), Times.Once()); }
public async Task ListRates_CallsListRatesMethodFromServicesLayer_WichThrowsAnException() { Mock <IRateBusiness> business = new Mock <IRateBusiness>(); business.Setup(m => m.ListRates()).Throws(exception); IRateService sut = new RateService(business.Object, commonFakes.Mapper); try { await sut.ListRates(); Assert.IsTrue(false, "No exception thrown. Exception exception was expected."); } catch (Exception result) { Assert.AreSame(exception, result); } }