Ejemplo n.º 1
0
        public void GetBillsReturnsListOfBills()
        {
            var data               = SetupExpectedBillDataModels();
            var dbSetMock          = SetupMockDbSet(data);
            var dbContextMock      = SetupMockDbContext(dbSetMock);
            var stubDataRepository = new StubDataRepository(dbContextMock.Object);
            var rssClientMock      = new Mock <IRssClient>();
            var billsService       = new BillsService(stubDataRepository, rssClientMock.Object);

            List <BillViewModel> result = billsService.GetAllBills();

            Assert.IsTrue(result.Count == 2);
        }
Ejemplo n.º 2
0
        public void UpdateBillDataPopulatesDatabaseWhenEmpty()
        {
            var data               = new List <BillDataModel>().AsQueryable();
            var dbSetMock          = SetupMockDbSet(data);
            var dbContextMock      = SetupMockDbContext(dbSetMock);
            var stubDataRepository = new StubDataRepository(dbContextMock.Object);
            var rssClientMock      = new Mock <IRssClient>();

            rssClientMock.Setup(x => x.GetBills(It.IsAny <string>())).Returns(SetupExpectedBillDataModels().ToList);

            var billsService = new BillsService(stubDataRepository, rssClientMock.Object);

            //billsService.UpdateBillData();
            dbContextMock.Verify(x => x.Set <BillDataModel>());
        }
Ejemplo n.º 3
0
 public BankScrapperAppService(
     IMapper mapper,
     AccountsService accountsService,
     BillsService billsService,
     CardsService cardsService,
     CategoriesService categoriesService,
     CustomersService customersService,
     TransactionsService transactionsService)
 {
     _mapper              = mapper ?? throw new ArgumentNullException(nameof(mapper));
     _accountsService     = accountsService ?? throw new ArgumentNullException(nameof(accountsService));
     _billsService        = billsService ?? throw new ArgumentNullException(nameof(billsService));
     _cardsService        = cardsService ?? throw new ArgumentNullException(nameof(cardsService));
     _categoriesService   = categoriesService ?? throw new ArgumentNullException(nameof(categoriesService));
     _customersService    = customersService ?? throw new ArgumentNullException(nameof(customersService));
     _transactionsService = transactionsService ?? throw new ArgumentNullException(nameof(transactionsService));
 }
        public async Task GetAllByCustomerIdAsyncShouldWorkCorrectly()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var billRepo = new EfDeletableEntityRepository <Bill>(dbContext);

            var service = new BillsService(billRepo);

            var customerId = Guid.NewGuid().ToString();
            var url        = Guid.NewGuid().ToString();

            await service.CreateAsync(customerId, url);

            var bills = await service.GetAllByCustomerIdAsync <BillModel>(customerId);

            Assert.Single(bills);
            Assert.Collection(
                bills,
                x => Assert.Equal(url, x.Url));
        }
        public async Task CreateAsyncShouldWorkCorrectly()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var billRepo = new EfDeletableEntityRepository <Bill>(dbContext);

            var service = new BillsService(billRepo);

            var customerId = Guid.NewGuid().ToString();
            var url        = Guid.NewGuid().ToString();

            await service.CreateAsync(customerId, url);

            var bill = await billRepo.AllAsNoTracking()
                       .FirstOrDefaultAsync(x => x.Id == 1);

            var count = await billRepo.AllAsNoTracking().CountAsync();

            Assert.Equal(1, count);
            Assert.Equal(customerId, bill.CusotmerId);
            Assert.Equal(url, bill.URL);
        }