public void CanSearchByNameAndSport() { var request = new SearchForFriendsRequest {ProfileName = Name1, Sport = Sport, Location = ""}; SetupProfileRepoToReturnThreeProfilesForName(); var handler = new SearchForFriendsRequestHandle(_mockProfileRepo.Object); var response = handler.Handle(request); Assert.That((object) response.Results.Count, Is.EqualTo(2)); }
public void CanSearchByLocationOnly() { var request = new SearchForFriendsRequest { ProfileName = "", Sport = "", Location = Location }; SetupProfileRepoToReturnTForLocationQuery(); var handler = new SearchForFriendsRequestHandle(_mockProfileRepo.Object); var response = handler.Handle(request); Assert.That(response.Results.Count, Is.EqualTo(1)); }
public ActionResult Search(SearchForFriendModel model) { var request = new SearchForFriendsRequest { Location = model.Location, ProfileName = model.ProfileName, Sport = model.Sport, MyProfile = GetProfileFromCookie() }; var handler = new SearchForFriendsRequestHandle(new ProfileRepository()); var response = handler.Handle(request); model.Results = response.Results; return View(model); }
public void ReturnsBadResponseCodeIfNoFieldsWereSpecified() { var request = new SearchForFriendsRequest { ProfileName = "", Sport = "", Location = "" }; var handler = new SearchForFriendsRequestHandle(_mockProfileRepo.Object); var response = handler.Handle(request); Assert.That(response.Status, Is.EqualTo(ResponseCodes.NoCriteriaSpecified)); }
public void DoesNotFindSelf() { var request = new SearchForFriendsRequest { ProfileName = Name1, Sport = "", Location = "", MyProfile = "MyProfile" }; var profile = new Profile {ProfileName = request.MyProfile}; var friendProfile = new Profile {ProfileName = Name1}; var listOfProfiles = new List<Profile> {profile, friendProfile}; var mockProfileRepo = new Mock<IProfileRepository>(); mockProfileRepo.Setup(x => x.FindAllByName(request.ProfileName)).Returns(listOfProfiles); var handler = new SearchForFriendsRequestHandle(mockProfileRepo.Object); var response = handler.Handle(request); Assert.That(response.Results.Count, Is.EqualTo(1)); Assert.That(response.Results[0], Is.SameAs(friendProfile)); }
public void CanSearchBySportOnly() { var request = new SearchForFriendsRequest { ProfileName = "", Sport = Sport, Location = "" }; SetupProfileRepoForSports(); var handler = new SearchForFriendsRequestHandle(_mockProfileRepo.Object); var response = handler.Handle(request); Assert.That(response.Results.Count, Is.EqualTo(2)); }