public IActionResult RegisterTapeLoan(int?tapeId, int?friendId)
 {
     if (friendId == null || tapeId == null)
     {
         throw new ResourceNotFoundException();
     }
     return(StatusCode(201, _tapeService.RegisterTapeLoan(tapeId, friendId)));
 }
Example #2
0
        public void RegisterTapeLoan()
        {
            // arrange
            int friendId = 1;
            int tapeId   = 1;

            _tapeRepositoryMock.Setup(method => method.RegisterTapeLoan(tapeId, friendId)).Returns(
                FizzWare.NBuilder.Builder <BorrowDto>
                .CreateNew().With(x => x.Id = 1).With(x => x.FriendId = friendId).With(x => x.ReturnDate = null)
                .With(x => x.BorrowDate     = DateTime.Today).Build());

            // act
            var borrow = _tapeService.RegisterTapeLoan(tapeId, friendId);

            // assert
            Assert.IsNotNull(borrow);
            Assert.AreEqual(friendId, borrow.FriendId);
            Assert.AreEqual(tapeId, borrow.TapeId);
            Assert.AreEqual(null, borrow.ReturnDate);
        }