public IActionResult GetFriendLoans(int?friendId) { if (friendId == null) { throw new ResourceNotFoundException(); } return(Ok(_tapeService.GetFriendLoans(friendId))); }
public void GetFriendLoans_TestIfNull() { // arrange int friendId = 1; _tapeRepositoryMock.Setup(method => method.GetFriendLoans(friendId)).Returns( FizzWare.NBuilder.Builder <BorrowDto> .CreateListOfSize(2) .TheFirst(1).With(x => x.Id = 1).With(x => x.FriendId = friendId).With(x => x.ReturnDate = null) .With(x => x.BorrowDate = DateTime.Today) .TheNext(1).With(x => x.Id = 2).With(x => x.FriendId = friendId).With(x => x.ReturnDate = null) .With(x => x.BorrowDate = DateTime.Now) .Build()); // act var result = _tapeService.GetFriendLoans(friendId); // assert Assert.AreEqual(2, result.Count()); Assert.IsNotNull(result); Assert.AreNotEqual(3, result.Count()); }