public void Invitation_Is_Received_By_The_Correct_Users()
        {
            LoginSteps.LoginTestUser1();
            FriendsSteps.RemoveUserFromFriends(TestUsers.TestUser2);
            FriendsSteps.AddUserToFriends(TestUsers.TestUser2);

            LoginSteps.LoginTestUser2();
            this.UserStartPage.UnacceptedInvitationsLink.Wait.ForExists();

            // Reverse to initial state (the two test users ARE friends)
            FriendsSteps.AcceptUserInvitation();
        }
        public void Request_Notification_Disappears_After_Friendship_Approval()
        {
            LoginSteps.LoginTestUser1();
            FriendsSteps.RemoveUserFromFriends(TestUsers.TestUser2);
            FriendsSteps.AddUserToFriends(TestUsers.TestUser2);

            LoginSteps.LoginTestUser2();
            this.UserStartPage.UnacceptedInvitationsLink.Wait.ForExists();

            FriendsSteps.AcceptUserInvitation();
            this.Browser.Refresh();

            this.UserStartPage.UnacceptedInvitationsLink.Wait.ForExistsNot();
        }
        public void Removing_A_Friend_Removes_Him_From_Your_Friends_List()
        {
            LoginSteps.LoginTestUser1();
            FriendsSteps.RemoveUserFromFriends(TestUsers.TestUser2);

            NavigateTo.Page(this.FriendsPage);
            Manager.Current.ActiveBrowser.RefreshDomTree();
            this.FriendsPage.Elements.NoFriendsMessage.Wait.ForExists(5000);

            // Reverse to initial state (the two test users ARE friends)
            FriendsSteps.AddUserToFriends(TestUsers.TestUser2);
            LoginSteps.LoginTestUser2();
            FriendsSteps.AcceptUserInvitation();
        }
        public void Requesting_A_Friendship_Does_Not_Add_User_To_Your_Friends_Without_Approval()
        {
            LoginSteps.LoginTestUser1();
            FriendsSteps.RemoveUserFromFriends(TestUsers.TestUser2);
            FriendsSteps.AddUserToFriends(TestUsers.TestUser2);

            NavigateTo.Page(this.FriendsPage);

            this.FriendsPage.Elements.SentInvitationsList.Wait.ForExists(5000);

            // Reverse to initial state (the two test users ARE friends)
            LoginSteps.LoginTestUser2();
            FriendsSteps.AcceptUserInvitation();
        }
        public void Invitation_Notification_Link_Navigates_To_The_Correct_Place()
        {
            LoginSteps.LoginTestUser1();
            FriendsSteps.RemoveUserFromFriends(TestUsers.TestUser2);
            FriendsSteps.AddUserToFriends(TestUsers.TestUser2);

            LoginSteps.LoginTestUser2();
            this.UserStartPage.UnacceptedInvitationsLink.Click();
            this.Browser.WaitUntilReady();

            Assert.AreEqual(this.FriendsPage.Url, this.Browser.Url);

            // Reverse to initial state (the two test users ARE friends)
            FriendsSteps.AcceptUserInvitation();
        }
        public void New_Messages_Sent_Invoke_New_Messages_Notification()
        {
            LoginSteps.LoginTestUser1();

            string messageContent = RandomDataGenerator.GenerateRandomString(5, 15);

            MessagesSteps.SendMessageTo(TestUsers.TestUser2, messageContent);

            LoginSteps.LoginTestUser2();

            this.StartPageElements.NewMessagesLink.AssertIsPresent();

            // Reverse to initial state (there are no unread messages between the users)
            MessagesSteps.ReadNewMessages();
        }
        public void New_Messages_Notification_Is_Removed_After_The_Message_Is_Read()
        {
            LoginSteps.LoginTestUser1();

            string messageContent = RandomDataGenerator.GenerateRandomString(5, 15);

            MessagesSteps.SendMessageTo(TestUsers.TestUser2, messageContent);

            LoginSteps.LoginTestUser2();

            this.StartPageElements.NewMessagesLink.AssertIsPresent();
            MessagesSteps.ReadNewMessages();

            NavigateTo.Url("http://test.telerikacademy.com/");
            this.StartPageElements.NewMessagesLink.AssertIsNotPresent();
        }
        public void Messages_Sent_Are_Received_By_The_Recepient()
        {
            LoginSteps.LoginTestUser1();

            string messageContent = RandomDataGenerator.GenerateRandomString(5, 15);

            MessagesSteps.SendMessageTo(TestUsers.TestUser2, messageContent);

            LoginSteps.LoginTestUser2();

            NavigateTo.Page(this.MessagesPage);

            this.MessagesPage.Elements.FriendTile.Click();

            this.MessagesPage.Elements.Messages.Wait.ForExists(5000);

            Assert.IsTrue(this.MessagesPage.Elements.Messages.InnerText.Contains(messageContent));

            // Reverse to initial state (there are no unread messages between the users)
            MessagesSteps.ReadNewMessages();
        }