public void User_Route_EditUser()
        {
            // data
            var userData = new UserGenerator();

            // page objects
            var userPages = new UserPages(_driver);

            try
            {
                _test.Log(LogStatus.Info, "Creating user");
                userData.CreateInDatabase();

                var userUrl = $"{_driver.Url}?Destination=UsersPage&Id={userData.Id}";
                _driver.Navigate().GoToUrl(userUrl);
                _test.Log(LogStatus.Info, $"Navigate to {userUrl}");

                _driver.SwitchToFrameById("MainContentsIFrame");
                Assert.IsTrue(userPages.CreateNewUserPage.IsDisplayed(), "The Edit User page is not displayed");
                _test.Log(LogStatus.Pass, "The Edit User page is dispalyed");

                _driver.SwitchToFrameById("tabs_Panel");
                Assert.IsTrue(userPages.CreateNewUserPage.ShortNameFieldContains(userData.UserName), "The Shortname field does not contain the correct username");
                _test.Log(LogStatus.Pass, "The username in the Shortname field is correct");
            }
            catch (Exception e)
            {
                HandleException(e, _driver);
                throw;
            }
            finally
            {
                userData.DeleteFromDatabase();
            }
        }
        public void UserSor_Delete_User()
        {
            var user = new UserGenerator();

            try
            {
                user.CreateInDatabase();
                _test.Log(LogStatus.Info, $"Created user: {user.Id} - {user.UserName}");
                user.DeleteFromDatabase();
                _test.Log(LogStatus.Info, "Deleted user");

                // wait a few seconds for the data to be sent
                Thread.Sleep(TimeSpan.FromSeconds(WaitTime));

                var userSyncData =
                    ApiHelpers.GetProductAccessUserResponse(
                        $"{TestEnvironment.DefaultUserType}",
                        new IdCreator(TestEnvironment.ClientCode, (int)user.Id, user.UserName).ToString());

                Assert.AreEqual(userSyncData.StatusCode, HttpStatusCode.NotFound, "The API did not respond with a 404");
                _test.Log(LogStatus.Pass, "The API responded with a 404");
            }
            catch (Exception e)
            {
                ReportException(e);
                throw;
            }
        }
        public void UserSor_Update_User()
        {
            var user             = new UserGenerator();
            var userDataAccessor = new UserDataAccessor();

            try
            {
                user.CreateInDatabase();
                _test.Log(LogStatus.Info, $"Created user: {user.Id} - {user.UserName}");

                var createdUser = userDataAccessor.GetUser(user.Id);
                createdUser.FullName = "Newfirst Newlast";
                createdUser.Email    = "*****@*****.**";
                userDataAccessor.UpdateUser(createdUser);

                // wait a few seconds for the data to be sent
                Thread.Sleep(TimeSpan.FromSeconds(WaitTime));

                var userSyncData =
                    ApiHelpers.GetProductAccessUser($"{TestEnvironment.DefaultUserType}",
                                                    new IdCreator(TestEnvironment.ClientCode, (int)user.Id, user.UserName).ToString());

                Assert.AreEqual(createdUser.FirstName, userSyncData["FirstName"], "First name does not match");
                _test.Log(LogStatus.Pass, "The changed first name matches");

                Assert.AreEqual(createdUser.LastName, userSyncData["LastName"], "Last name does not match");
                _test.Log(LogStatus.Pass, "The changed last name matches");

                Assert.AreEqual(createdUser.Email, userSyncData["Email"], "Email does not match");
                _test.Log(LogStatus.Pass, "The changed email matches");

                user.DeleteFromDatabase();
            }
            catch (Exception e)
            {
                ReportException(e);
                throw;
            }
        }
        public void UserSor_Create_User()
        {
            var user = new UserGenerator();

            try
            {
                user.CreateInDatabase();
                _test.Log(LogStatus.Info, $"Created user: {user.Id} - {user.UserName}");

                // wait a few seconds for the data to be sent
                Thread.Sleep(TimeSpan.FromSeconds(WaitTime));

                var userSyncData =
                    ApiHelpers.GetProductAccessUser($"{TestEnvironment.DefaultUserType}",
                                                    new IdCreator(TestEnvironment.ClientCode, (int)user.Id, user.UserName).ToString());

                Assert.IsTrue(String.IsNullOrWhiteSpace(userSyncData["Flid"].ToString()), "The Flid is not null");
                _test.Log(LogStatus.Pass, "The Flid is null");

                Assert.AreEqual(user.FirstName, userSyncData["FirstName"], "First name does not match");
                _test.Log(LogStatus.Pass, "The first names match");

                Assert.AreEqual(user.LastName, userSyncData["LastName"], "Last name does not match");
                _test.Log(LogStatus.Pass, "The last names match");

                Assert.AreEqual(user.Email, userSyncData["Email"], "Email does not match");
                _test.Log(LogStatus.Pass, "The emails match");

                Assert.IsTrue(String.IsNullOrWhiteSpace(userSyncData["ExternalId"].ToString()), "ExternalId is not null");
                _test.Log(LogStatus.Pass, "The external ID is null");

                user.DeleteFromDatabase();
            }
            catch (Exception e)
            {
                ReportException(e);
                throw;
            }
        }
        public void User_Create_New()
        {
            // data
            var userData = new UserGenerator();

            // page objects
            var mainMenu  = new MainMenu(_driver);
            var userMenu  = new SubMenuUsers(_driver);
            var userPages = new UserPages(_driver);

            // helpers
            var userDataAccessor = new UserDataAccessor();

            try
            {
                mainMenu.ClickUsers();
                userMenu.ClickCreateNewUser();
                _test.Log(LogStatus.Info, "Navigate to Users > Create a new user");

                _driver.SwitchToFrameById("MainContentsIFrame");
                Assert.IsTrue(userPages.CreateNewUserPage.IsDisplayed(),
                              "The 'Create a new user' page is not displayed");
                _test.Log(LogStatus.Pass, "The 'Create a new user' page is displayed");

                // enter user info
                _driver.SwitchToFrameById("tabs_Panel");

                userPages.CreateNewUserPage.EnterShortName(userData.UserName);
                _test.Log(LogStatus.Info, "Enter username: "******"Enter real name: " + userData.RealName);

                userPages.CreateNewUserPage.EnterEmail(userData.Email);
                _test.Log(LogStatus.Info, "Enter user email: " + userData.Email);

                //save
                _driver.SwitchToDefaultFrame();
                _driver.SwitchToFrameById("MainContentsIFrame");
                userPages.CreateNewUserPage.ClickSaveButton();
                userPages.CreateNewUserPage.ClickSaveAndCloseButton();
                _test.Log(LogStatus.Info, "Saving user");

                Assert.IsInstanceOfType(userDataAccessor.GetUser(userData.UserName), typeof(RecruitUser),
                                        "The user was not created in the database");
                _test.Log(LogStatus.Pass, "User was created in the database");

                Assert.IsTrue(userPages.ListUsersPage.IsDisplayed(), "The 'List all users' page is not displayed");
                _test.Log(LogStatus.Pass, "The 'List all users' page should be displayed after clicking Save and Close");

                // set the ID in order find the user on the 'List all users' page and to delete the user
                userData.Id = userDataAccessor.GetUser(userData.UserName).Id;
                Assert.IsTrue(userPages.ListUsersPage.ItemFound(userData.Id.ToString()),
                              "The user is listed on the List all users page");
                _test.Log(LogStatus.Pass, "User is listed on the List all users page");

                userData.DeleteFromDatabase();
            }
            catch (Exception e)
            {
                HandleException(e, _driver);
                throw;
            }
        }