public async Task GetBills_ShouldReturnBills_Correctly() { // Arrange var client = await apiFunctionalTestFixture.CreateAuthorizedClientAsync(); var user = new UserBuilder().Id(apiFunctionalTestFixture.UserId).Build(); var account = new AccountBuilder().Owner(user).Build(); var bill = new BillBuilder() .WithAccount(account) .CreatedByUser(user).Build(); apiFunctionalTestFixture.SetupDatabase(db => { db.Bill.Add(bill); }); // Act var response = await client.GetAsync("/api/bill"); var result = await response.ResolveAsync <PagedResult <BillDto> >(); // Assert response.EnsureSuccessStatusCode(); Assert.NotNull(result); Assert.Single(result.Value); Assert.Equal(1, result.TotalCount); AssertBillDtoEqualModel(bill, result.Value.First()); }
public void HasCreated_ShouldReturnTrue_IfUserHasCreatedBill() { // Arrange var user = new User(Guid.NewGuid(), "John"); var account = user.CreateAccount("Checking account"); var bill = new BillBuilder().CreatedByUser(user).WithAccount(account).Build(); // Act && Assert Assert.True(bill.HasCreated(user.Id)); }
public void ShareWithUser_ShouldAddUserToBills_Correctly() { // Arrange var user = new User(Guid.NewGuid(), "John"); var anotherUser = new User(Guid.NewGuid(), "Phil"); var account = user.CreateAccount("Checking account"); var bill = new BillBuilder().CreatedByUser(user).WithAccount(account).Build(); // Act bill.ShareWithUser(anotherUser); // Assert Assert.Collection(bill.SharedWithUsers, b => { Assert.Equal(anotherUser, b.User); }); }
public string GetBill() { var billBuilder = new BillBuilder(); return(billBuilder.Build(Bracket)); }