public IActionResult GetTapeById(int?id) { if (id == null) { throw new ResourceNotFoundException(); } return(Ok(_tapeService.GetTapeById((int)id))); }
public void GetTapeById_ReturnsTapeDetailDTO() { // act var result = service.GetTapeById(1); // assert Assert.IsInstanceOfType(result, typeof(TapeDetailDTO)); Assert.AreEqual("Test Movie 1", result.Title); Assert.AreEqual(1, result.BorrowHistory.Count()); _tapeRepository.Verify((m => m.GetTapeById(1)), Times.Once()); }
public void GetTapeById_TestingNotNull() { // arrange _tapeRepositoryMock.Setup(method => method.GetTapeById(1)).Returns( FizzWare.NBuilder.Builder <TapeDetailsDto> .CreateNew().With(x => x.Id = 1).With(x => x.Eidr = "1").With(x => x.Title = "Pulp Fiction") .With(x => x.Type = "VHS").With(x => x.AverageRating = 2.2) .With(x => x.DirectorName = "Quentin Tarantino") .With(x => x.ReleaseDate = DateTime.Today).Build()); // act var tape = _tapeService.GetTapeById(1); // assert Assert.IsNotNull(tape); Assert.AreEqual("Pulp Fiction", tape.Title); Assert.AreEqual("Quentin Tarantino", tape.DirectorName); }
//Returns random movie the user hasn't seen public TapeDetailDTO GetRecommendation(int userId) { var user = _userService.GetUserById(userId); var tapes = _tapeService.GetAllTapes(""); var reviews = _reviewService.GetAllReviewsForAllTapes(); var userBorrowedTapeIds = user.BorrowHistory.Select(u => u.TapeId).ToArray(); var unseenTapes = tapes.Where(t => !userBorrowedTapeIds.Contains(t.Id)).ToList(); // var reviewedTapeIds = reviews.OrderByDescending(r => r.Score).Select(r => r.TapeId).ToArray(); // var reviewedTapes = unseenTapes.Where(t => reviewedTapeIds.Contains(t.Id)).ToList(); // Getting random movie that user hasn't seen Random rnd = new Random(); int randomIndex = rnd.Next(0, unseenTapes.Count() - 1); var tapeId = unseenTapes.Select(t => t.Id).ElementAt(randomIndex); return(_tapeService.GetTapeById(tapeId)); }
public IActionResult GetTapeById(int id) => Ok(_tapeService.GetTapeById(id));
public IActionResult GetTapeById(int tapeId) { return(Ok(_tapeService.GetTapeById(tapeId))); }
public void GetTapeById_ShouldReturnCorrectTape() { var tape = _tapeService.GetTapeById(_tapeMockListSize); Assert.AreEqual(tape.Id, _tapeMockListSize); }