Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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'");
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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);
            }
        }