public async Task GetSelfLoansAsync_WhenSelfLoansExist_ShouldReturnSelfLoans()
        {
            //Arrange
            var         sutBuilder    = new LoansServiceSutBuilder();
            var         loans         = sutBuilder.Setup();
            List <Loan> filteredLoans = loans.Where(u => u.LoaneeId == u.Bill.LoanerId).ToList();
            var         loanService   = sutBuilder.CreateSut();

            var loanerId  = loans[0].Bill.LoanerId;
            var loaneeId  = loans[0].Bill.LoanerId;
            var groupId   = loans[0].Loanee.Groups[0].Id;
            var startTime = DateTime.Now.AddMilliseconds(-1000);
            var endTime   = DateTime.Now.AddMilliseconds(1000);

            var expectedFilter = A.Fake <LoanDbFilter>();

            A.CallTo(() => sutBuilder.LoanDbFilterFactory.Create(A <LoanFilterInfo> .That.Matches(passedInfo =>
                                                                                                  passedInfo.LoanerId == loanerId &&
                                                                                                  passedInfo.GroupId == groupId &&
                                                                                                  passedInfo.StartTime == startTime &&
                                                                                                  passedInfo.EndTime == endTime &&
                                                                                                  passedInfo.LoaneeId == loaneeId
                                                                                                  ))).Returns(expectedFilter);

            A.CallTo(() => sutBuilder.LoanRepository.GetAllAsync(expectedFilter))
            .Returns(filteredLoans);

            //Act
            var resultLoans = await loanService.GetSelfLoansAsync(loaneeId, groupId, startTime, endTime);

            //Assert
            resultLoans.ShouldBe(filteredLoans);
        }
            public List <Loan> Setup()
            {
                var sutBuilder = new LoansServiceSutBuilder();
                var group      = sutBuilder.CreateGroupWithUsers("Test group", 0);
                var loaner     = sutBuilder.CreateUser(name: "loaner", group: group);
                var loanee     = sutBuilder.CreateUser(name: "loanee", group: group);
                var user1      = sutBuilder.CreateUser(name: "user1", group: group);
                var user2      = sutBuilder.CreateUser(name: "user2", group: group);
                var groupUsers = new List <User>
                {
                    loaner,
                    loanee,
                    user1,
                    user2
                };
                var billToCreate = sutBuilder.CreateNewBill("Shopping", 120, group.Id, loaner.Id);
                var bill         = new Bill()
                {
                    Id             = Guid.NewGuid(),
                    Name           = billToCreate.Name,
                    Total          = billToCreate.Total,
                    LoanerId       = loaner.Id,
                    Loaner         = loaner,
                    GroupContextId = group.Id,
                    GroupContext   = group,
                };
                var loans = groupUsers
                            .Select((user, index) => new Loan()
                {
                    BillId   = bill.Id,
                    Bill     = bill,
                    LoaneeId = user.Id,
                    Loanee   = user,
                    Amount   = 30
                }).ToList();

                return(loans);
            }