Ejemplo n.º 1
0
        public async Task Get_CodeIsNull_ShouldThrow()
        {
            // Arrange
            var options = BuildContextOptions();

            using (var context = new BorrowBuddyContext(options)) {
                var service = new CurrencyService(context);

                // Act
                // Assert
                await Assert.ThrowsAsync <ArgumentNullException>(() => service.GetAsync(null));
            }
        }
Ejemplo n.º 2
0
        public async Task Get_DontExist_ShouldReturnNull()
        {
            // Arrange
            var options = BuildContextOptions();

            using (var context = new BorrowBuddyContext(options)) {
                var service = new CurrencyService(context);
                // Act
                var result = await service.GetAsync("code");

                // Assert
                Assert.Null(result);
            }
        }
Ejemplo n.º 3
0
        public async Task Get_Exists_ShouldReturnCurrency()
        {
            // Arrange
            var options = BuildContextOptions();

            using (var context = new BorrowBuddyContext(options)) {
                context.AddCurrency("code");
                context.SaveChanges();
            }

            using (var context = new BorrowBuddyContext(options)) {
                var service = new CurrencyService(context);

                // Act
                var result = await service.GetAsync("code");

                // Assert
                Assert.NotNull(result);
            }
        }
Ejemplo n.º 4
0
 public async Task <ActionResult <IEnumerable <Currency> > > GetCurrency()
 {
     return((await _currencyService.GetAsync()).Select(Mapper.Map).ToList());
 }