Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public void GivenIHaveFriendsList_WhenITryToGetNearFriendWithouInformWhatFriendIamVisit_ThenIShouldReceiveAThrowException()
        {
            //arrange
            var friendsList       = HelperTest.PrepareAFriendsUnorderedList();
            var friendBusinessSut = new MyFriends(friendsList);

            //act
            var friendNear = friendBusinessSut.GetNearFriendsTop3()[0];

            //assert
            Assert.AreEqual("Friend K", friendNear.Name);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }