public void UpdateTestSuccess()
        {
            DeleteDummyAccount();


            try
            {
                var id         = CreateDummyAccount();
                var permission = new Permission(id);
                permission.AddPermission("None");
                var permUpdate = new PermissionUpdateSqlService(_dao, permission);
                var result     = permUpdate.Update();


                Assert.AreEqual(result.IsSuccess, true);
                var permission2 = new Permission(id);
                permission2.RemovePermission("None");
                var permUpdate2 = new PermissionUpdateSqlService(_dao, permission2);
                var result2     = permUpdate2.Update();
                Assert.AreEqual(result2.IsSuccess, true);

                DeleteDummyAccount();
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.ToString());
                Assert.Fail();
            }
        }
        public void UpdateTestFailure()
        {
            DeleteDummyAccount();
            CreateDummyAccount();

            try
            {
                var permission = new Permission(-1);
                permission.AddPermission("None");
                var permUpdate = new PermissionUpdateSqlService(_dao, permission);
                var result     = permUpdate.Update();



                Assert.Fail();
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.ToString());
                DeleteDummyAccount();
            }
        }
        public IResult CreateAccount(Account account, User user)
        {
            var users = new List <User> {
                user
            };
            var accounts = new List <Account> {
                account
            };

            _createAccountService._newAccounts = accounts;
            _updateAccountService._newUsers    = users;
            for (int i = 0; i < 3; i++)
            {
                try
                {
                    var createAccountResult = _createAccountService.Create();
                    if (createAccountResult.IsSuccess)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    ErrorController handler = new ErrorController();
                    handler.Handle(e);
                }
                if (i == 2)
                {
                    throw new Exception("Failed to create Account");
                }
            }
            for (int i = 0; i < 3; i++)
            {
                try
                {
                    var updateAccountResult = _updateAccountService.Update();
                    if (updateAccountResult.IsSuccess)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    ErrorController handler = new ErrorController();
                    handler.Handle(e);
                }
                if (i == 2)
                {
                    throw new Exception("Failed to create Account");
                }
            }
            var        id    = _updatePermissionService.SysIdFinder(user);
            Permission perms = new Permission(id);

            foreach (string s in Enum.GetValues(typeof(StandardUser)))
            {
                perms.AddPermission(s);
            }
            for (int i = 0; i < 3; i++)
            {
                try
                {
                    _updatePermissionService._permissions = new List <Permission> {
                        perms
                    };
                    var permResult = _updatePermissionService.Update();
                    if (permResult.IsSuccess)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    ErrorController handler = new ErrorController();
                    handler.Handle(e);
                }
                if (i == 2)
                {
                    throw new Exception("Failed to create Permissions");
                }
            }


            var checkResult = new CheckResult("Account Successfully Created", true);

            LogService.Log(checkResult.Message);
            return(checkResult);
        }