Exemplo n.º 1
0
        public async Task GetAvailableCurrenciesReturnsEmptyArrayGivenNoCurrencyIsRegistered()
        {
            //Arrange
            var context = CreateEmptyContext();
            var service = new CurrencyReadingService(context);
            //Act
            var currencies = await service.GetAvailableCurrenciesAsync();

            //Assert
            Assert.IsNotNull(currencies);
            Assert.AreEqual(0, currencies.Length);
        }
Exemplo n.º 2
0
        public async Task GetAvailableCurrenciesReturnsEmptyArrayGivenNoCurrencyIsEnabled()
        {
            //Arrange
            var context = CreateEmptyContext();

            context.CurrencySymbols.Add(new CurrencySymbol("USD")
            {
                Enabled = false
            });
            await context.SaveChangesAsync();

            var service = new CurrencyReadingService(context);
            //Act
            var currencies = await service.GetAvailableCurrenciesAsync();

            //Assert
            Assert.IsNotNull(currencies);
            Assert.AreEqual(0, currencies.Length);
        }
Exemplo n.º 3
0
        public async Task GetAvailableCurrenciesReturnsGivenCurrencyAreEnabled()
        {
            //Arrange
            var context = CreateEmptyContext();

            context.CurrencySymbols.Add(new CurrencySymbol("USD"));
            context.CurrencySymbols.Add(new CurrencySymbol("EUR"));
            await context.SaveChangesAsync();

            var service = new CurrencyReadingService(context);

            //Act
            var currencies = await service.GetAvailableCurrenciesAsync();

            //Assert
            Assert.IsNotNull(currencies);
            Assert.AreEqual(2, currencies.Length);
            Assert.IsTrue(currencies.Contains("USD"));
            Assert.IsTrue(currencies.Contains("EUR"));
        }
        public async Task <IActionResult> Get()
        {
            var currencies = await _service.GetAvailableCurrenciesAsync();

            return(Ok(currencies));
        }