public void GivenIHaveFriendsListInNegativePositions_WhenIVisitAFriendZeta_ThenIShouldKnowWhichAre3FriendsNear() { //arrange var friendsNameThatImVisiting = "Friend Zeta"; var friendsList = HelperTest.PrepareAFriendsListWithNegativePositions(); friendsList.Add(new Friend(friendsNameThatImVisiting, new Position(-40, -50))); var friendBusinessSut = new MyFriends(friendsList); friendBusinessSut.VisitAFriend(friendsNameThatImVisiting); var msgError = "This friend doesn't exist in the List: top3FriendsNear"; //act var top3FriendsNear = friendBusinessSut.GetNearFriendsTop3(); var friendsExpected = friendsList.FindAll(_ => _.Name == "Friend K" || _.Name == "Friend W" || _.Name == "Friend Y"); //assert CollectionAssert.Contains(top3FriendsNear, friendsExpected[0], msgError); CollectionAssert.Contains(top3FriendsNear, friendsExpected[1], msgError); CollectionAssert.Contains(top3FriendsNear, friendsExpected[2], msgError); }
static void Main(string[] args) { Console.WriteLine("Starting program Nearby Friends \n"); var friendsList = GetAFriendsList(); PresenterFriends(); string friendOnVisit; string confirmationChoice; GetUserChoice(out friendOnVisit, out confirmationChoice); while (confirmationChoice.Trim().ToUpper() != "S") { GetUserChoice(out friendOnVisit, out confirmationChoice); } try { var friendBusiness = new MyFriends(friendsList); friendBusiness.VisitAFriend(friendOnVisit); var nearFriends = friendBusiness.GetNearFriendsTop3(); PresenterNearFriends(nearFriends); } catch (Exception) { Console.WriteLine("Occurred an error during the execution of program. Please try again.\nIf the error persist please contact the Administrator"); Thread.Sleep(4000); } Console.WriteLine("\nEnding the program"); Thread.Sleep(4000); }
public void GivenIHaveFriends_WhenIWantVisitAFriendSigmaAndHeDoesntExistImMyList_ThenIShouldReceiveAThrowException() { //arrange string friendsNameThatImVisiting = "Friend Sigma"; var friendsList = HelperTest.PrepareAFriendsList_B(); var friendBusinessSut = new MyFriends(friendsList); //act friendBusinessSut.VisitAFriend(friendsNameThatImVisiting); }
public void GivenIHaveFriends_WhenIVisitAFriendBeta_ThenIShouldKnowWhatFriendIsNear() { //arrange const string friendsNameThatImVisiting = "Friend Beta"; var friendsList = HelperTest.PrepareAFriendsList_B(); friendsList.Add(new Friend(friendsNameThatImVisiting, new Position(-1, -20))); var friendBusinessSut = new MyFriends(friendsList); //act friendBusinessSut.VisitAFriend(friendsNameThatImVisiting); var friendsNear = friendBusinessSut.GetNearFriendsTop3(); //assert Assert.AreEqual("Friend A", friendsNear[0].Name); }
public void GivenIHaveFriendsListValid_WhenIVisitAFriendZeta_ThenIShouldKnowOnlyTop3FriendsNear() { //arrange const string friendsNameThatImVisiting = "Friend Zeta"; var friendsList = HelperTest.PrepareAFriendsList(); friendsList.Add(new Friend(friendsNameThatImVisiting, new Position(25, 18))); var friendBusinessSut = new MyFriends(friendsList); friendBusinessSut.VisitAFriend(friendsNameThatImVisiting); //act var top3FriendsNear = friendBusinessSut.GetNearFriendsTop3(); //assert Assert.AreEqual(3, top3FriendsNear.Count); }
public void GivenIHaveFriendsUnorderedListAndIInsertAFriendOnVisitingAt0Position_WhenIVisitAFriendOmega_ThenIShouldKnowWhatFriendIsNear() { //arrange var friendsList = HelperTest.PrepareAFriendsUnorderedList(); string friendsNameThatImVisiting = "Friend Omega"; friendsList.Insert(0, new Friend(friendsNameThatImVisiting, new Position(25, 18))); //act var friendBusinessSut = new MyFriends(friendsList); friendBusinessSut.VisitAFriend(friendsNameThatImVisiting); var friendNear = friendBusinessSut.GetNearFriendsTop3()[0]; //assert Assert.AreEqual("Friend K", friendNear.Name); }
public void GivenIHaveFriendsListValid_WhenIVisitAFriendZeta_ThenIShouldKnowWhichAre3FriendsNear() { //arrange const string friendsNameThatImVisiting = "Friend Zeta"; var friendsList = HelperTest.PrepareAFriendsList_B(); friendsList.Add(new Friend(friendsNameThatImVisiting, new Position(33, 31))); var friendBusinessSut = new MyFriends(friendsList); friendBusinessSut.VisitAFriend(friendsNameThatImVisiting); //act var top3FriendsNear = friendBusinessSut.GetNearFriendsTop3(); //assert Assert.AreEqual("Friend K", top3FriendsNear[0].Name); Assert.AreEqual("Friend Y", top3FriendsNear[1].Name); Assert.AreEqual("Friend Z", top3FriendsNear[2].Name); }