public void Recommendations_GetRecommendationsForUser_WithOneMatch() { // Arrange var repo = new RecommendationsRepository(context); int userId = (context.Users.OrderByDescending(b => b.Id).FirstOrDefault()).Id; context.Books.Add(new Book { Title = "Silmarillion", Author = AUTHOR_LOTR, ReleaseDate = new DateTime(1977, 9, 15), ISBN = "0987654321", Available = true, Deleted = false }); context.SaveChanges(); // Act var recommendations = repo.GetRecommendationsForUser(userId); // Assert Assert.AreEqual(1, recommendations.Count()); Assert.AreEqual("Silmarillion", recommendations.Where(b => b.Title == "Silmarillion").SingleOrDefault().Title); Assert.AreEqual("J.R.R. Tolkien", recommendations.Where(b => b.Title == "Silmarillion").SingleOrDefault().Author); Assert.AreEqual("0987654321", recommendations.Where(b => b.Title == "Silmarillion").SingleOrDefault().ISBN); }
public void Recommendations_GetRecommendationsForUser_WithNoMatchSoRandomResults() { // Arrange var repo = new RecommendationsRepository(context); int userId = (context.Users.OrderByDescending(b => b.Id).FirstOrDefault()).Id; for (int i = 1; i <= 5; i++) { context.Books.Add(new Book { Title = ("Book " + i), Author = ("Author " + i), ReleaseDate = new DateTime(1977, 9, 15), ISBN = i.ToString(), Available = true, Deleted = false }); } context.SaveChanges(); // Act var recommendations = repo.GetRecommendationsForUser(userId); // Assert Assert.AreEqual(5, recommendations.Count()); Assert.AreEqual("Book 1", recommendations.Where(b => b.Title == "Book 1").SingleOrDefault().Title); Assert.AreEqual("Book 2", recommendations.Where(b => b.Title == "Book 2").SingleOrDefault().Title); Assert.AreEqual("Book 3", recommendations.Where(b => b.Title == "Book 3").SingleOrDefault().Title); Assert.AreEqual("Book 4", recommendations.Where(b => b.Title == "Book 4").SingleOrDefault().Title); Assert.AreEqual("Book 5", recommendations.Where(b => b.Title == "Book 5").SingleOrDefault().Title); }
public RecommendationsController(RecommendationsRepository repo, RecPhotosRepository photosrepo, RelationshipsRepository relationshipsrepo, UsersRepository usersrepo) { _repo = repo; _photosRepo = photosrepo; _relationshipsRepo = relationshipsrepo; _usersrepo = usersrepo; }
private void CreateRepositories() { HttpClient = new HttpClient(); HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken); Albums = new AlbumRepository(HttpClient, new Uri(BaseUri, AlbumRepository.DEFAULT_ENDPOINT)); Artists = new ArtistRepository(HttpClient, new Uri(BaseUri, ArtistRepository.DEFAULT_ENDPOINT)); Browse = new BrowseRepository(HttpClient, new Uri(BaseUri, BrowseRepository.DEFAULT_ENDPOINT)); Episodes = new EpisodeRepository(HttpClient, new Uri(BaseUri, EpisodeRepository.DEFAULT_ENDPOINT)); Recommendations = new RecommendationsRepository(HttpClient, new Uri(BaseUri, RecommendationsRepository.DEFAULT_ENDPOINT)); _search = new SearchRepository(HttpClient, new Uri(BaseUri, SearchRepository.DEFAULT_ENDPOINT)); }
public void TestAllDecisions() { IDecisionsRepository decs = new DecisionsRepository(); IRecommendationsRepository recs = new RecommendationsRepository(); int i = decs.GetAllDecisionsPerParagraph(12).Count; // int j = recs.getAllRecommendationsByParagraph(12).Count; Assert.AreEqual(i, 2); }
public void Recommendations_GetRecommendationsForUser_InvalidUserId() { // Arrange var repo = new RecommendationsRepository(context); int userId = Int32.MaxValue; // Act var recommendations = repo.GetRecommendationsForUser(userId); // Assert Assert.Fail("Should have thrown NotFoundException"); }
public ActionResult CreateRecommendation(FormCollection collection) { try { // TODO: Add insert logic here string recommendation = collection["recommendation"].ToString(); int committee_id = int.Parse(collection["Committees"].ToString()); DateTime recdeadlinedate = DateTime.Parse(collection["recdeadlinedate"].ToString()); DateTime recdate = DateTime.Parse(collection["recdate"].ToString()); int PActionID = int.Parse(collection["SourceID"].ToString()); IRecommendationsRepository recs = new RecommendationsRepository(); IGenericRepository generic = new GenericRepository(); Recommendation r = new Recommendation(); r.AddedDate = DateTime.Now; r.CommitteeID = committee_id; r.DeadlineDate = recdeadlinedate; r.RecDate = recdate; r.RecommendationX = recommendation; r.ParagraphActionID = PActionID; int i = recs.SaveRec(r); ViewData["Committees"] = new SelectList(generic.getAllCommitteesSelect(), "ID", "Description"); ViewData["recommendations"] = recs.getAllRecommendationsByParagraph(PActionID); ViewData["PActionID"] = PActionID; return(PartialView("Recommendations")); //return RedirectToAction("Index"); } catch { return(View()); } }