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 User_Delete()
        {
            // data
            var userData = new UserGenerator();

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

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

                // delete the user
                mainMenu.ClickUsers();
                userMenu.ClickUsersList();
                _driver.SwitchToFrameById("MainContentsIFrame");
                userPages.ListUsersPage.MarkItem(userData.Id.ToString());
                _test.Log(LogStatus.Info, "Select user");

                userPages.ListUsersPage.ClickDeleteUser();
                _test.Log(LogStatus.Info, "Click delete");

                userPages.ListUsersPage.ConfirmDeletion();
                _test.Log(LogStatus.Info, "Click 'Yes' to delete the user");

                // Navigate back to the List all users page
                // This is to get around a bug in the system which causes the deleted user to be displayed until page is refreshed
                mainMenu.ClickMainMenuTab();
                mainMenu.ClickUsers();
                userMenu.ClickUsersList();
                _driver.SwitchToFrameById("MainContentsIFrame");
                Assert.IsFalse(userPages.ListUsersPage.ItemFound(userData.Id.ToString()), "User was not deleted");
                _test.Log(LogStatus.Pass, "The user was deleted successfully");
            }
            catch (Exception e)
            {
                HandleException(e, _driver);
                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;
            }
        }