Esempio n. 1
0
        public async Task Balance_ShouldCancelEachOtherAsync()
        {
            // Arrange
            var         options = BuildContextOptions();
            Participant from;
            Participant to;
            Currency    currency;

            using (var context = new BorrowBuddyContext(options)) {
                currency = context.AddCurrency();
                from     = context.AddParticipant();
                to       = context.AddParticipant();
                context.AddFlow(from, to, currency, 50);
            }

            using (var context = new BorrowBuddyContext(options)) {
                var service = new BalanceService(context);
                // Act
                var positive = await service.BalanceAsync(from.Id, to.Id, currency.Code);

                var negative = await service.BalanceAsync(to.Id, from.Id, currency.Code);

                // Assert
                Assert.Equal(50, positive);
                Assert.Equal(-50, negative);
            }
        }
Esempio n. 2
0
 public async Task <ActionResult <long> > BalanceAsync(Guid from, Guid to, string code)
 {
     return(await _balanceService.BalanceAsync(from, to, code));
 }