public async Task Confirm(int borrowId) { Borrow borrowDomain = await GetBorrowAsync(borrowId); borrowDomain.Confirm(); await this._borrowRepository.Save(borrowDomain); }
public void GivenBorrowWhenBorrowConfirmThenProductBorrowed() { User borrower = new User("Test"); User lender = new User("Test1"); Product product = new Product(lender, "Test", "Test", new ProductType(), new Term(DateTime.Now.AddDays(-6), DateTime.Now)); Borrow borrow = new Borrow(borrower, product, new Term(DateTime.Now.AddDays(-2), DateTime.Now.AddDays(-1))); product.Status.Should().Be(ProductStatus.Shary); borrow.Status.Should().Be(BorrowStatus.Created); borrow.IsLender(lender).Should().BeTrue(); borrow.IsBorrower(borrower).Should().BeTrue(); borrow.Confirm(); product.Status.Should().Be(ProductStatus.Borrowed); borrow.Status.Should().Be(BorrowStatus.Accepted); }
public async Task GivenBorrowServiceWhenCloseWithBorrowFoundAndAcceptedThenIsUpdated() { Borrow borrowDomain = FakeBuilder.GetBorrowFake(); borrowDomain.Confirm(); Assert.True(borrowDomain.Status == BorrowStatus.Accepted); this._mockBorrowRepository.Setup(repo => repo.Get(It.IsAny <int>())) .ReturnsAsync(borrowDomain); await this._borrowService.Close(borrowDomain.BorrowId); this._mockBorrowRepository.Verify(mock => mock.Save(It.IsAny <Borrow>()), Times.Once); Assert.True(borrowDomain.Status == BorrowStatus.Closed); }
public async Task GivenBorrowServiceWhenRejectWithBorrowFoundAndConfirmedThenStatusInvalidException() { Borrow borrowDomain = FakeBuilder.GetBorrowFake(); borrowDomain.Confirm(); Assert.True(borrowDomain.Status == BorrowStatus.Accepted); this._mockBorrowRepository.Setup(repo => repo.Get(It.IsAny <int>())) .ReturnsAsync(borrowDomain); await Assert.ThrowsAsync <StatusInvalidException>(() => this._borrowService.Reject(borrowDomain.BorrowId)); this._mockBorrowRepository.Verify(mock => mock.Save(It.IsAny <Borrow>()), Times.Never); }