コード例 #1
0
        public void GivenNewAccount_WhenInsert_ThenSendEmail()
        {
            //ARRANGE
            mockmail.Expect(x => x.Send("", "", "")).IgnoreArguments().Return(true);

            //ACT
            sut.AddAccount(new Account(), "");

            //ASSERT
            mockmail.VerifyAllExpectations();
        }
コード例 #2
0
        public void GivenNewAccount_WhenInsert_ThenReturnNotNull()
        {
            var uow = new UoW(_chatContext);

            using (var dbContextTransaction = uow.BeginTransaction())
            {
                try
                {
                    //ARRANGE
                    Account account = new Account();
                    account.UserName = "******";
                    account.Password = "******";

                    _sendEmailStub.Stub(se => se.Send("", "", "")).IgnoreArguments().Return(true);

                    //ACT
                    var newaccount = _sut.AddAccount(account, null);

                    //ASSERT
                    var insertedAccount = _accountRepository.Get(account.AccountID);
                    Assert.NotNull(insertedAccount);
                    Assert.Equal(insertedAccount.Password, newaccount.Password);
                }
                finally
                {
                    dbContextTransaction.Rollback();
                }
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            //i know password  is clear no hash, no salt no pepper ..:)
            try
            {
                ChatContext        ctx = new ChatContext();
                IAccountRepository accountRepository = new AccountRepository(ctx);
                ISendEmail         sendEmail         = new SendEmail();
                ILogData           logData           = new LogData();
                AccountService     accountService    = new AccountService(sendEmail, accountRepository, logData, ctx);

                Account account = new Account();
                account.UserName = "******";
                account.Password = "******";
                //todo add email in profile entity
                accountService.AddAccount(account, "*****@*****.**");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex);
                //throw;
            }



            Console.WriteLine("Demo complete.");
            Console.ReadLine();
        }
コード例 #4
0
        private ActionResult DoRegister(AccountCreateViewModel model, Guid sellerGuid, string token, string returnUrl)
        {
            bool isRegisterValidEmail    = isValidEmail(model.EmailAddress);
            bool isRegisterValidPassword = isValidPassword(model.Password);

            if (isRegisterValidEmail && isRegisterValidPassword)
            {
                ABUser currentUser         = AccountService.GetUserByUserName(model.EmailAddress);
                var    currentUserGuid     = currentUser.ABUserGUID;
                var    currentUserToken    = currentUser.Token;
                Guid   tempCurrentUserGuid = sellerGuid;



                if (tempCurrentUserGuid == currentUserGuid && currentUserToken == token && isRegisterValidEmail)
                {
                    var hashedPassword        = Utilities.CreatePasswordHash(model.Password, model.EmailAddress);
                    AccountCreateViewModel vm = new AccountCreateViewModel();
                    vm.Password        = hashedPassword;
                    vm.EmailAddress    = model.EmailAddress;
                    vm.ConfirmPassword = hashedPassword;
                    vm.Alias           = model.Alias;

                    ServiceResult result = new ServiceResult();
                    result = AccountService.AddAccount(vm);
                    if (result.Success)
                    {
                        return(RedirectToAction("RegisterSuccess", result));
                    }
                    return(RedirectToAction("RegisterFail", result));
                }
            }
            return(null);
        }
コード例 #5
0
ファイル: NoAccountsWidget.cs プロジェクト: xlizzard/synapse
        private void on_saveAccountButton_clicked()
        {
            JID jid = null;

            if (String.IsNullOrEmpty(m_LoginLineEdit.Text))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Login may not be empty.");
            }
            else if (!JID.TryParse(m_LoginLineEdit.Text, out jid))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Login should look like 'user@server'.");
            }
            else if (String.IsNullOrEmpty(new JID(m_LoginLineEdit.Text).User))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Login should look like 'user@server'.");
            }
            else if (String.IsNullOrEmpty(m_PasswordLineEdit.Text))
            {
                QMessageBox.Critical(this.TopLevelWidget(), "Synapse", "Password may not be empty");
            }
            else
            {
                var            accountInfo = new AccountInfo(jid.User, jid.Server, m_PasswordLineEdit.Text, "Synapse");
                AccountService service     = ServiceManager.Get <AccountService>();
                service.AddAccount(accountInfo);
            }
        }
コード例 #6
0
        public ActionResult AddJournalist(JournalistViewmodel journalist)
        {
            User    user    = new User();
            Account account = new Account();

            user.UserId      = journalist.UserId;
            user.UserName    = journalist.UserName;
            user.Email       = journalist.Email;
            user.DateOfBirth = journalist.DateOfBirth;
            user.Gender      = journalist.Gender;
            user.Role        = 2;
            user.Phone       = journalist.Phone;


            try
            {
                var temp = _userService.AddUser(user);
                if (temp != null)
                {
                    account.AccountName = journalist.AccountName;
                    account.Password    = journalist.Password;
                    account.UserId      = temp.UserId;
                    account.Active      = 1;
                    var acc = _accountService.AddAccount(account);
                    if (acc != null)
                    {
                        return(View("Index"));
                    }
                }
            }catch (Exception)
            {
                return(View("AddJournalist"));
            }
            return(View("AddJournalist"));
        }
コード例 #7
0
 public MyResult <object> AddMemberAdd_Update([FromBody] BackstageUserAdd model)
 {
     if (!string.IsNullOrEmpty(model.Id))
     {
         return(AccountService.UpdateAccount(model));
     }
     return(AccountService.AddAccount(model));
 }
コード例 #8
0
ファイル: AccountServiceTest.cs プロジェクト: uwitec/ideacode
        public void TestAddAccount()
        {
            //DBHelper.ConnectionString = "Server=rd01;Database=LiveSupport;User ID=sa;Password=;Trusted_Connection=False;";
            Account account = createAccount(1111);

            AccountService.Provider = new MyAccountProvider();
            AccountService.AddAccount(account);
            Assert.AreSame(AccountService.FindAccountByLoginName(account.LoginName), account);
        }
コード例 #9
0
ファイル: AccountServiceTest.cs プロジェクト: uwitec/ideacode
        public void testGetAccountById()
        {
            DBHelper.ConnectionString = "Server=rd01;Database=LiveSupport;User ID=sa;Password=;Trusted_Connection=False;";
            Account account = createAccount(1111);

            AccountService.AddAccount(account);
            string accountid = AccountService.FindAccountByLoginName(account.LoginName).AccountId;

            Assert.AreSame(AccountService.GetAccountById(accountid), account);
        }
コード例 #10
0
        public void TestAddAccount_HolderAndBaseType_Account()
        {
            var repositoryMock = new Mock <IRepository <DTOAccount> >();

            repositoryMock.Setup(repo => repo.Items).Returns(new List <DTOAccount>());
            repositoryMock.Setup(repo => repo.Add(It.IsAny <DTOAccount>()));
            var accountService = new AccountService(_accountIdService, repositoryMock.Object);

            accountService.AddAccount(new Holder(), "Base");
        }
コード例 #11
0
        public void AddAccountTest()
        {
            Account testAccount = new Account();

            testAccount.Email    = "*****@*****.**";
            testAccount.Password = "******";
            int newId = svc.AddAccount(testAccount);

            Assert.True(newId >= 0);
        }
コード例 #12
0
        static void Main(string[] args)
        {
            AccountType goldType     = new AccountType(0, "Gold", 8, 9);
            AccountType baseType     = new AccountType(1, "Base", 3, 5);
            AccountType platinumType = new AccountType(2, "Platinum", 15, 13);

            AccountTypeService typeService = new AccountTypeService();

            typeService.AddType(goldType);
            typeService.AddType(baseType);
            typeService.AddType(platinumType);

            Account goldAccount     = new Account(0, 0, "Ivan", "Popov");
            Account baseAccount     = new Account(1, 1, "Denis", "Demenkovets");
            Account platinumAccount = new Account(2, 2, "Jack", "Hunter");

            IPointsCalculations calculator     = new PlusCalculator();
            AccountService      accountService = new AccountService(typeService, calculator);

            accountService.AddAccount(goldAccount);
            accountService.AddAccount(baseAccount);
            accountService.AddAccount(platinumAccount);

            PrintAccounts(accountService.GetAccounts());

            accountService.PutMoney(2, 10);
            accountService.WithdrawMoney(2, 5);
            PrintAccounts(accountService.GetAccounts());

            accountService.ChangeCalcLogics(new MultCalculator());
            accountService.PutMoney(2, 10);
            PrintAccounts(accountService.GetAccounts());

            typeService.ChangeType(2, 30, 13);
            accountService.PutMoney(2, 10);
            PrintAccounts(accountService.GetAccounts());

            accountService.SaveAccounts();
            typeService.SaveTypes();

            Console.ReadKey();
        }
コード例 #13
0
        public void TestAddAccountFailed()
        {
            var             repository     = new Mock <IRepository <Account> >();
            IAccountService accountService = new AccountService(repository.Object);

            foreach (var account in GetAccounts(false))
            {
                accountService.AddAccount(account);
            }
            repository.Verify(x => x.Add(It.IsAny <Account>()), Times.Never);
        }
コード例 #14
0
        public void TestAddAccountSuccessful()
        {
            var             repository     = new Mock <IRepository <Account> >();
            IAccountService accountService = new AccountService(repository.Object);

            foreach (var account in GetAccounts(true))
            {
                accountService.AddAccount(account);
            }
            repository.Verify(x => x.Add(It.IsAny <Account>()), Times.Exactly(accounts.Count(x => x.Value == true)));
        }
コード例 #15
0
        public void Register(SharedAccount sAccount)
        {
            Debug.WriteLine(AccountProvider.GetFeaturesByAppId("tlwr"));
            Account account = Account.CreateAccount();

            account.UserName    = sAccount.name;
            account.DisplayName = sAccount.displayName;
            account.DomainName  = sAccount.domainName;
            account.EmailId     = sAccount.email;
            account.IconPath    = sAccount.iconPath;
            AccountService.AddAccount(account);
        }
コード例 #16
0
        public async Task AssertAddAccountValuesAreSetAsync()
        {
            //Given
            var id      = Guid.NewGuid().ToString();
            var account = new Account(id, accountName, accountPassword);
            var ar      = new ActionResult <Account>()
            {
                resposeObject = account, statusCode = HttpStatusCode.Created
            };

            _mockRepo.Setup(m => m.AddAccount(It.IsAny <Account>())).Returns(Task.FromResult(ar));

            //When
            var result = await _accountService.AddAccount(accountName, accountPassword);

            //Then
            _mockRepo.Verify(m => m.AddAccount(It.IsAny <Account>()));
            Assert.Equal(accountName, result.resposeObject.Name);
            Assert.Equal(accountPassword, result.resposeObject.Password);
            Assert.Equal(HttpStatusCode.Created, result.statusCode);
        }
コード例 #17
0
 public JsonResult SignUp(Account newAccount)
 {
     try
     {
         auth.AddAccount(newAccount);
         return(Json(RespоnceManager.CreateSucces("Аккаунт успешно добавлен!")));
     }
     catch (Exception ex)
     {
         // в случае неудачи возвращаем причину
         return(Json(RespоnceManager.CreateError(ex)));
     }
 }
コード例 #18
0
ファイル: Form1.cs プロジェクト: LucasAssis1/Rampup.PI
 private void btnSend_Click(object sender, EventArgs e)
 {
     try
     {
         //passing named parameters to the addAccount method in AccountService
         _service.AddAccount(name: txtUserName.Text, personType: cbbPersonType.Text, accountType: cbbAccountType.Text, account_ID: txtAccount.Text, agency: txtAgency.Text, balance: txtBalance.Text);
         ClearInputs_Register();
         FillListView();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #19
0
        public void AddAccount_AddNew()
        {
            Account acc = new Account(new List <Card> {
                new Card("1111111111111111", "1111")
            }, 0);

            _accountService.AddAccount(acc);

            acc = new Account(new List <Card> {
                new Card("1111111111111112", "1111")
            }, 0);
            _accountService.AddAccount(acc);

            Assert.AreEqual(2, _accountService.Accounts.Count);
            Assert.AreEqual(acc.Cards[0].Number, _accountService.Accounts[1].Cards[0].Number);
        }
コード例 #20
0
        static void Main(string[] args)
        {
            AccountService service        = new AccountService();
            var            creditAccount1 = new CreditAccount();
            var            creditAccount2 = new CreditAccount();
            var            bonusAccount1  = new BonusAccount();
            var            bonusAccount2  = new BonusAccount();

            service.AddAccount(creditAccount1);
            service.AddAccount(creditAccount2);
            service.AddAccount(bonusAccount1);
            service.AddAccount(bonusAccount2);

            service.Deposit(1, 100);
            service.Deposit(3, 100);
            service.Withdraw(3, 90);
            service.Withdraw(1, 50);
            service.Withdraw(1, 50);
            service.Withdraw(1, 50);

            Console.WriteLine("Balance of first account: " + service.GetAccountById(1).Balance);
            Console.WriteLine("Balance of third account: " + service.GetAccountById(3).Balance);

            BinaryWriter writer = new BinaryWriter(File.Open("test.bin", FileMode.OpenOrCreate));

            service.Save(writer);
            writer.Dispose();

            AccountService service2 = new AccountService();
            BinaryReader   reader   = new BinaryReader(File.Open("test.bin", FileMode.OpenOrCreate));

            service2.Load(reader);

            Console.WriteLine("Balance of first account: " + service2.GetAccountById(1).Balance);
            Console.WriteLine("Balance of third account: " + service2.GetAccountById(3).Balance);
        }
コード例 #21
0
ファイル: Tests.cs プロジェクト: novopashinwm/OtusInterface
        public void Test1()
        {
            var mock = new Mock <IRepository <Account> >();

            mock.Setup(r => r.Add(It.IsAny <Account>()));
            IAccountService accServ = new AccountService(mock.Object);

            accServ.AddAccount(new Account()
            {
                FirstName   = "Ivan"
                , LastName  = "Sidoroff"
                , BirthDate = DateTime.Now
            });
            mock.Verify(rep => rep.Add(It.IsAny <Account>()));
        }
コード例 #22
0
        public void GivenNewAccount_WhenNullEmail_ThenThrow()
        {
            //ARRANGE
            AccountService sut        = new AccountService(new SendEmail(), _stubAccountRepository, logData, new ChatContext());
            var            newaccount = new Account()
            {
                UserName = "******",
                Password = "******"
            };

            //ACT
            Exception ex = Assert.Throws <ArgumentException>(() => sut.AddAccount(newaccount, null));

            //ASSERT
            Assert.Equal("Error : recipient must be a valid email", ex.Message);
        }
コード例 #23
0
        public void GivenNewAccount_WhenInsert_ThenSendEmailAndLog()
        {
            //ARRANGE
            mockmail = MockRepository.GenerateStrictMock <ISendEmail>();
            ILogData mocklogData = MockRepository.GenerateStrictMock <ILogData>();

            sut = new AccountService(mockmail, _stubAccountRepository, mocklogData, new ChatContext());
            mockmail.Expect(x => x.Send("", "", "")).IgnoreArguments().Return(true);
            mocklogData.Expect(x => x.LogThis("")).IgnoreArguments();

            //ACT
            sut.AddAccount(new Account(), "");

            //ASSERT
            //mockmail.VerifyAllExpectations();
        }
コード例 #24
0
        public void AddAccountTest()
        {
            DatabaseDriver databaseDriver = new DatabaseDriver(
                Database.DataSource,
                Database.InitialCatalog,
                Database.UserId,
                Database.Pwd,
                Database.PersistSecurityInfo
                );

            databaseDriver.Connect();
            AccountService accountService = new AccountService(ref databaseDriver);
            bool           result         = accountService.AddAccount("Coordinate35", "1234dsfadfas5asdfa", Database.AccountPrivilegeAdmin);

            Assert.IsTrue(result);
        }
コード例 #25
0
        public void AddUserAccount()
        {
            var user = new AccountModel()
            {
                FirstName = "Ryan",
                LastName  = "Kelton",
                //Username = Guid.NewGuid().ToString(),
                Username        = "******",
                Email           = "*****@*****.**",
                Password        = "******",
                PermissionLevel = (int)Permission.SITE_STANDARD
            };

            service.AddAccount(user);

            var result = unitOfWork.Save();

            Assert.AreEqual(true, result);
        }
コード例 #26
0
        /// <summary>
        /// Adds an account with UserId and UserPassword received from accountItem.
        /// You should get these from server communication in actual account provider.
        /// </summary>
        /// <param name="accountItem"> Account item to add.</param>
        /// <returns> The account ID of the account instance. </returns>
        public int AccountAdd(UserCredentials accountItem)
        {
            if (accountItem == null)
            {
                throw new ArgumentNullException(nameof(accountItem));
            }

            try
            {
                int id = -1;

                // Create account instance
                Tizen.Account.AccountManager.Account account = Tizen.Account.AccountManager.Account.CreateAccount();
                if (account == null)
                {
                    return(id);
                }

                // Add account with inputed id and password.
                // In sample app, just add id as user_name and password as access_token.
                // But, you should get these from server communication in actual account provider.
                account.UserName    = accountItem.Username;
                account.AccessToken = accountItem.Password;
                account.SyncState   = AccountSyncState.Idle;

                // Insert account DB with the new account information.
                // AddAccount returns account id.

                // ApplicationManager.GetAppId()
                // var accountProvider = AccountService.GetAccountProviderByAppId();
                var appInfo         = Tizen.Applications.Application.Current.ApplicationInfo;
                var accountprovider = AccountService.GetAccountProviderByAppId(appInfo.ApplicationId);
                var providers       = AccountService.GetAccountProviders();
                id = AccountService.AddAccount(account);
                return(id);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error Message : " + e.ToString());
                return(-1);
            }
        }
コード例 #27
0
ファイル: fAdmin.cs プロジェクト: docaotri123/QuanLyQuanAn
        private void btnAddAccount_Click(object sender, EventArgs e)
        {
            string userName = txbUserName.Text.ToString();
            int    temp     = (int)numericUpDownType.Value;
            bool   type     = Convert.ToBoolean(temp);
            bool   test     = account.AddAccount(userName, type);

            if (test == true)
            {
                MessageBox.Show("Thêm tài khoản thành công");
            }
            else
            {
                MessageBox.Show("Tài khoản đã trùng tên, vui lòng thay đổi thông tin");
            }

            txbUserName.DataBindings.Clear();
            ListAccount();
            txbUserName.DataBindings.Add(new Binding("Text", dtgvAccount.DataSource, "userName", true, DataSourceUpdateMode.Never));
        }
コード例 #28
0
        public void TestInvite()
        {
            LiveSupport.LiveSupportDAL.SqlProviders.DBHelper.ConnectionString = "Server=rd01;Database=LiveSupport;User ID=sa;Password=;Trusted_Connection=False;";
            OperatorService.Provider = new MyOperatorProvider();
            Account a = TestTool.CreateNewAccount();

            AccountService.AddAccount(a);
            Operator o = TestTool.CreateNewOperator(a.AccountId);

            OperatorService.NewOperator(o);
            Visitor v = TestTool.CreateNewVisitor(a.AccountId);

            VisitorService.NewVisitor(v);
            VisitSessionService.NewSession(v.CurrentSession);

            Operator op = OperatorService.Login(a.LoginName, a.LoginName, a.Password);

            ChatService.OperatorRequestChat(op.OperatorId, v.VisitorId);

            Assert.AreEqual(v.CurrentSession.SessionId, ChatService.GetOperatorInvitation(v.VisitorId));
        }
コード例 #29
0
        public int AddAccount(Dictionary <string, string> UserInfo)
        {
            // To do: Add validation
            string userName     = UserInfo["accountName"];
            string passwd       = UserInfo["passwd"];
            int    privilege    = UserInfo.ContainsKey("privilege") ? Convert.ToInt32(UserInfo["privilege"]) : Database.AccountPrivilegeUser;
            string hashedPasswd = BCrypt.Net.BCrypt.HashPassword(passwd);

            bool isAccountExist = accountService.IsAccountExist(userName);

            if (isAccountExist)
            {
                return(ControllerReturnCode.ACCOUNTADDACCOUNTDUPLICATE);
            }
            bool result = accountService.AddAccount(userName, hashedPasswd, privilege);

            if (!result)
            {
                return(ControllerReturnCode.ACCOUNTADDACCOUNTERROR);
            }
            return(ControllerReturnCode.ACCOUNTADDACCOUNTSUCCESS);
        }
コード例 #30
0
        /// <summary>
        /// Adds an account with UserId and UserPassword received from accountItem.
        /// You should get these from server communication in actual account provider.
        /// </summary>
        /// <param name="accountItem"> Account item to add.</param>
        /// <returns> The account ID of the account instance. </returns>
        public int AccountAdd(AccountItem accountItem)
        {
            if (accountItem == null)
            {
                throw new ArgumentNullException(nameof(accountItem));
            }

            try
            {
                int id = -1;

                // Create account instance
                Account account = Account.CreateAccount();
                if (account == null)
                {
                    return(id);
                }

                // Add account with inputed id and password.
                // In sample app, just add id as user_name and password as access_token.
                // But, you should get these from server communication in actual account provider.
                account.UserName    = accountItem.UserName;
                account.AccessToken = accountItem.UserPassword;
                account.SyncState   = AccountSyncState.Idle;

                // Insert account DB with the new account information.
                // AddAccount returns account id.
                id = AccountService.AddAccount(account);

                return(id);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error Message : " + e.ToString());
                return(-1);
            }
        }