public async Task Setup() { var reader = AccountBuilder.InLibrary(LibraryId).As(Role.Reader).Build(); _chapter = ChapterBuilder.WithLibrary(LibraryId).WithContents().WithoutAnyAssignment().Build(); _response = await Client.PostObject($"/libraries/{LibraryId}/books/{_chapter.BookId}/chapters/{_chapter.ChapterNumber}/assign", new { AccountId = reader.Id, Type = "write" }); }
public Response CreateCustomerClass(string line_of_business, string policy_type, string vehicle_type, string zone, string country, string channel, string supervisor, int supervisor_code, string custclass, string GpProductID) { RMCustomerClass rmcustclass = new RMCustomerClass(); AccountBuilder aBuilder = new AccountBuilder(); Response response; Customers custom = new Customers(); string taxid = ConfigKey.ReadSetting("TAXID"); string accountREC = ConfigKey.ReadSetting("IDREC"); string company = ConfigKey.ReadSetting("Company"); try { rmcustclass.CLASSID = custclass; rmcustclass.CLASDSCR = custclass; rmcustclass.CRLMTTYP = 1; rmcustclass.TAXSCHID = taxid; rmcustclass.STMTCYCL = 5; rmcustclass.CUSTPRIORITY = 1; rmcustclass.ORDERFULFILLDEFAULT = 1; rmcustclass.ACCTRECACCT = aBuilder.BuildARAccount(Convert.ToInt32(accountREC), line_of_business, policy_type, vehicle_type, country, channel, supervisor, supervisor_code, GpProductID); response = custom.CreateCustomerClass(rmcustclass, company); return(response); } catch (Exception ex) { log.LogExeption("Ocurrió un error: ", 2, ex); throw; } }
public async void UpdateAccountAfterAddingIt() { // add an account var repository = GetRepository(); var initialName = "Teste"; var account = new AccountBuilder().Name(initialName).Balance(500).Build(); await repository.Add(account); // detach the account so we get a different instance _dbContext.Entry(account).State = EntityState.Detached; // fetch the account and change its name var newAccount = repository.GetAccounts().GetAwaiter().GetResult() .FirstOrDefault(a => a.Name == initialName); Assert.NotNull(newAccount); Assert.NotSame(account, newAccount); var newName = Guid.NewGuid().ToString(); newAccount.Name = newName; // Update the name await repository.Update(newAccount); var updatedItem = repository.GetAccounts().GetAwaiter().GetResult() .FirstOrDefault(a => a.Name == newName); Assert.NotNull(updatedItem); Assert.NotEqual(account.Name, updatedItem.Name); Assert.Equal(newAccount.Id, updatedItem.Id); }
private Bill CreateBillEntityWithDate(DateTime date) { var accountEntity = new AccountBuilder().Owner(this.user).Build(); return(new BillBuilder().WithDate(date) .WithAccount(accountEntity).CreatedByUser(this.user).Build()); }
public async Task GetBills_ShouldReturnBills_Correctly() { // Arrange var client = await apiFunctionalTestFixture.CreateAuthorizedClientAsync(); var user = new UserBuilder().Id(apiFunctionalTestFixture.UserId).Build(); var account = new AccountBuilder().Owner(user).Build(); var bill = new BillBuilder() .WithAccount(account) .CreatedByUser(user).Build(); apiFunctionalTestFixture.SetupDatabase(db => { db.Bill.Add(bill); }); // Act var response = await client.GetAsync("/api/bill"); var result = await response.ResolveAsync <PagedResult <BillDto> >(); // Assert response.EnsureSuccessStatusCode(); Assert.NotNull(result); Assert.Single(result.Value); Assert.Equal(1, result.TotalCount); AssertBillDtoEqualModel(bill, result.Value.First()); }
public async Task RefreshToken_Successfully() { // Arrange AccountCreatePrarams accountParams = new AccountBuilder().Build(); // Act // Create basic user HttpResponseMessage createAccountResponse = await AccountHelper.SubmitCreateAccountRequest(accountParams, _token); createAccountResponse.EnsureSuccessStatusCode(); var isRecordFound = AccountHelper.IsRecoundFound(accountParams.Username); // Login HttpResponseMessage loginResponse = await AccountHelper.SubmitLoginRequest(accountParams.Email, accountParams.Password); createAccountResponse.EnsureSuccessStatusCode(); IResult <TokenResponse> tokenInfo = await loginResponse.ToResult <TokenResponse>(); // Refresh token HttpResponseMessage refreshTokenResponse = await AccountHelper.SubmitRefreshTokenRequest(tokenInfo.Data.RefreshToken, tokenInfo.Data.Token); refreshTokenResponse.EnsureSuccessStatusCode(); IResult <TokenResponse> refreshToken = await loginResponse.ToResult <TokenResponse>(); // Assert Assert.IsTrue(isRecordFound); Assert.IsNotNull(tokenInfo); Assert.IsNotNull(refreshToken); Assert.IsTrue(refreshToken.Succeeded); Assert.IsNotNull(refreshToken.Data); Assert.IsNotNull(refreshToken.Data.Token); Assert.IsNotNull(refreshToken.Data.RefreshToken); }
public AccountView() { Account = new Account(); Builder = new AccountBuilder(Account); Controller = new AccountController(); InitializeComponent(); }
private void button_AddAccount_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(textBox_UserName.Text) || string.IsNullOrEmpty(textBox_Password.Text) || string.IsNullOrEmpty(textBox_DisplayName.Text)) { MessageBox.Show("Hãy điền đầy đủ thông tin tài khoản bạn muốn thêm", "Thông báo"); } else { string UserName = textBox_UserName.Text; string Password = textBox_Password.Text; string NameDisplay = textBox_DisplayName.Text; int Type = int.Parse(textBox_Type.Text); IAccountBuilder account = new AccountBuilder().SetUserName(UserName).SetPassword(Password).SetDisplayName(NameDisplay).SetTypeAccount(Type); AccountDAO.Instance.Create(account.Build()); textBox_UserName.Clear(); textBox_Password.Clear(); textBox_DisplayName.Clear(); LoadListAccount(); MessageBox.Show("Thêm tài khoản thành công", "Thông báo"); } } catch { MessageBox.Show("Tên tài khoản đã tồn tại. Hãy thử lại", "Thông Báo"); } }
private void button_UpdateAccount_Click(object sender, EventArgs e) { string UserName = textBox_UserName.Text; string Password = textBox_Password.Text; string NameDisplay = textBox_DisplayName.Text; bool checkAccount = AccountDAO.Instance.CheckExists(textBox_UserName.Text); if (checkAccount) { IAccountBuilder account = new AccountBuilder().SetUserName(UserName).SetPassword(Password).SetDisplayName(NameDisplay); AccountDAO.Instance.Update(account.Build()); textBox_UserName.Clear(); textBox_Password.Clear(); textBox_DisplayName.Clear(); LoadListAccount(); MessageBox.Show("Sửa tài khoản thành công", "Thông báo"); } else if (string.IsNullOrEmpty(textBox_UserName.Text)) { MessageBox.Show("Hãy chọn tài khoản mà bạn muốn sửa", "Thông Báo"); } else { MessageBox.Show("Tài khoản bạn muốn sửa không tồn tại", "Thông Báo"); } }
public async Task Setup() { var password = RandomData.String; var account = AccountBuilder.WithPassword(password).Verified().Build(); _response = await Client.PostObject("/accounts/authenticate", new AuthenticateRequest { Email = account.Email, Password = RandomData.String }); }
public async Task Login_With_Invalid_Credentials() { // Arrange AccountCreatePrarams accountParams = new AccountBuilder().Build(); string wrongPassword = Guid.NewGuid().ToString(); // Act // Create basic user HttpResponseMessage createAccountResponse = await AccountHelper.SubmitCreateAccountRequest(accountParams, _token); createAccountResponse.EnsureSuccessStatusCode(); var isRecordFound = AccountHelper.IsRecoundFound(accountParams.Username); HttpResponseMessage loginResponse = await AccountHelper.SubmitLoginRequest(accountParams.Email, wrongPassword); loginResponse.EnsureSuccessStatusCode(); IResult <TokenResponse> tokenInfo = await loginResponse.ToResult <TokenResponse>(); // Assert Assert.IsTrue(isRecordFound); Assert.IsNotNull(tokenInfo); Assert.IsNull(tokenInfo.Data); Assert.IsFalse(tokenInfo.Succeeded); Assert.AreEqual(tokenInfo.Messages[0], "Invalid Credentials."); }
public Account ToSDKAccount() { if (sdkAccount != null) { return(sdkAccount); } else if (apiAccount != null) { AccountBuilder builder = AccountBuilder.NewAccount() .WithCompany(new CompanyConverter(apiAccount.Company).ToSDKCompany()) .CreatedOn(apiAccount.Created) .UpdatedOn(apiAccount.Updated) .WithData(apiAccount.Data) .WithId(apiAccount.Id) .WithLogoUrl(apiAccount.LogoUrl) .WithOwner(apiAccount.Owner) .WithName(apiAccount.Name) .WithAccountProviders(new AccountProvidersConverter(apiAccount.Providers).ToSDKAccountProviders()); foreach (API.CustomField field in apiAccount.CustomFields) { builder.WithCustomField(new CustomFieldConverter(field).ToSDKCustomField()); } foreach (API.License license in apiAccount.Licenses) { builder.WithLicense(new LicenseConverter(license).ToSDKLicense()); } return(builder.Build()); } else { return(null); } }
public AccountService(IUnitOfWork unitOfWork, AccountBuilder accountBuilder, AccountAdapter accountAdapter, AccountBusinessRules accountBusinessRules, IEmailHandler emailHandler) { this.unitOfWork = unitOfWork; this.accountBuilder = accountBuilder; this.accountAdapter = accountAdapter; this.accountBusinessRules = accountBusinessRules; this.emailHandler = emailHandler; }
public void CanCreateLateAccount() { var account = AccountBuilder.DefaultAccount() .WithLatePaymentStatus() .Build(); Assert.IsTrue(account.DueDate < DateTime.Now); }
public async Task Setup() { var account = AccountBuilder.Verified() .AsInvitation().ExpiringInvitation(DateTime.Today.AddDays(-1)) .Build(); _response = await Client.GetAsync($"/accounts/invitation/{account.InvitationCode}"); }
public async Task Setup() { _library = LibraryBuilder.Build(); _account = AccountBuilder.InLibrary(_library.Id).AsInvitation().Build(); _response = await Client.PostObject($"/accounts/invitations", new ResendInvitationCodeRequest() { Email = _account.Email }); }
public async Task Setup() { var authResponse = await AccountBuilder.Authenticate(Client, Account.Email); _response = await Client.PostObject("/accounts/revoke-token", new RevokeTokenRequest() { Token = authResponse.RefreshToken }); }
public void CanCreateLateAccountWithVipCustomer() { var account = AccountBuilder.DefaultAccount() .WithLatePaymentStatus() .WithVipCustomer() .Build(); Assert.IsTrue(account.Customer.IsVip); }
public async Task Setup() { _account = AccountBuilder.Verified().Build(); _response = await Client.PostObject("/accounts/forgot-password", new ForgotPasswordRequest() { Email = _account.Email }); }
public async Task Setup() { var account = AccountBuilder.Build(); _book = BookBuilder.WithLibrary(LibraryId).WithPages(20).AssignPagesTo(account.Id, 15).Build(); _response = await Client.GetAsync($"/libraries/{LibraryId}/books/{_book.Id}/pages?pageSize=10&pageNumber=1&assignmentFilter=assigned"); _assert = new PagingAssert <BookPageView>(_response); }
public AccountTestsFixture SetSenderAccountWithSentTransferConnection() { SenderAccount = new AccountBuilder() .WithSentTransferConnectionInvitation(new TransferConnectionInvitationBuilder() .WithStatus(TransferConnectionInvitationStatus.Pending) .Build()) .Build(); return(this); }
public void SetUp() { mockAccountRepository = new Mock <IAccountRepository>(); mockNotificationService = new Mock <INotificationService>(); fromAccountBuilder = new AccountBuilder().WithId(fromAccountId).WithUser(fromUser); mockAccountRepository.Setup(m => m.GetAccountById(fromAccountId)).Returns(fromAccountBuilder); sut = new WithdrawMoney(mockAccountRepository.Object, mockNotificationService.Object); }
public void ShouldReduceWithdrawn() { Account sut = new AccountBuilder().WithWithdrawn(0m); sut.Debit(250m); var expected = -250m; Assert.AreEqual(expected, sut.Withdrawn); }
public void ShouldIncreaseBalance() { Account sut = new AccountBuilder().WithBalance(1000m); sut.Credit(250m); var expected = 1250m; Assert.AreEqual(expected, sut.Balance); }
public async Task Setup() { var account = AccountBuilder.Build(); BookBuilder.WithLibrary(LibraryId).IsPublic().AddToFavorites(AccountId).Build(25); _response = await Client.GetAsync($"/libraries/{LibraryId}/books?pageNumber=1&pageSize=10&favorite=true"); _assert = new PagingAssert <BookView>(_response); }
public void ShouldIncreasePaidIn() { Account sut = new AccountBuilder().WithPaidIn(1000m); sut.Credit(250m); var expected = 1250m; Assert.AreEqual(expected, sut.PaidIn); }
public void ShouldReduceBalance() { Account sut = new AccountBuilder().WithBalance(1000m); sut.Debit(250m); var expected = 750m; Assert.AreEqual(expected, sut.Balance); }
public async Task Setup() { var account = AccountBuilder.Build(); _book = BookBuilder.WithLibrary(LibraryId).WithPages(20).WithStatus(_status, 15).Build(); _response = await Client.GetAsync($"/libraries/{LibraryId}/books/{_book.Id}/pages?pageSize=10&pageNumber=1&status={_status.ToDescription()}"); _assert = new PagingAssert <BookPageView>(_response); }
///<summary>Build new app instance</summary> ///<param name="developerSecret">Developer secret seed</param> ///<param name="address">User public key</param> ///<returns>Promise returns new app instance</returns> async public Task <App> Build(string developerSecret, string address) { var developerKeypair = Stellar.KeyPair.FromSecretSeed(developerSecret); var developerAccount = await AccountBuilder.Build(developerKeypair); var userKeypair = Stellar.KeyPair.FromAccountId(address); var userAccount = await AccountBuilder.Build(userKeypair); return(new App(developerAccount, userAccount)); }
public AccountTestsFixture SetSenderAccountWithReceivedTransferConnectionFromReceiverAccount() { SenderAccount = new AccountBuilder() .WithReceivedTransferConnectionInvitation(new TransferConnectionInvitationBuilder() .WithSenderAccount(ReceiverAccount) .WithStatus(TransferConnectionInvitationStatus.Approved) .Build()) .Build(); return(this); }