public void GivenMemberMapper_WhenMapMemberToMemberModel_ShouldMapSuccessful(long id, decimal monthlyExpense, decimal monthlySalary, string name, string emailAddress) { // assign var memberAccounts = new List <MemberAccount> { MemberDataBuilder.CreateMemberAccount(1, id, 2), }; var memberExpense = MemberDataBuilder.CreateMemberExpense(1, id, FrequencyIds.Month, monthlyExpense); var memberSalary = MemberDataBuilder.CreateMemberSalary(1, id, FrequencyIds.Month, monthlySalary); var member = MemberDataBuilder.CreateMember(id, memberAccounts, memberExpense, memberSalary, name, emailAddress); // act var memberModel = _mapper.Map <MemberModel>(member); // assert memberModel.ShouldSatisfyAllConditions( () => memberModel.ShouldNotBeNull(), () => memberModel.Name.ShouldBe(member.Name), () => memberModel.Email.ShouldBe(member.Email), () => memberModel.Id.ShouldBe(member.Id), () => memberModel.MonthlySalary.ShouldBe(member.MemberSalary.GetMonthlySalary()), () => memberModel.MonthlyExpense.ShouldBe(member.MemberExpense.GetMonthlyExpense()) ); }
public async Task GivenAccountRepository_WhenCallCreate_ShouldSuccess() { using (var context = await InMemoryDbContextFactory.CreateUserContext()) { // assign var testData = (memebrId : 0, accountId : 0, memebrAccountId : 1); var member = MemberDataBuilder.CreateMember(testData.memebrId, new List <MemberAccount>(), null, null); await context.Members.AddAsync(member); await context.SaveChangesAsync(); var memberAccount = MemberDataBuilder.CreateMemberAccount(testData.memebrAccountId, testData.accountId, testData.memebrId); var account = AccountDataBuilder.CreateAccount(testData.accountId, new List <MemberAccount> { memberAccount }); // act var repo = new AccountRepository(context); await repo.Create(account); await context.SaveChangesAsync(); // assert account.Id.ShouldBeGreaterThan(0); } }
public void GivenAccountMapper_WhenMapAccountToAccountModel_ShouldMapSuccessful(long id, AccountStatusIds accountStatusId, decimal accountBalance, decimal pendingBalance, string accountNumber) { // assign var memberAccounts = new List <MemberAccount> { MemberDataBuilder.CreateMemberAccount(1, id, 2), }; var account = AccountDataBuilder.CreateAccount(id, memberAccounts, accountStatusId, accountBalance, pendingBalance, accountNumber); account.AccountStatus = new AccountStatus { Id = (long)accountStatusId, Name = accountStatusId.ToString() }; // act var accountModel = _mapper.Map <AccountModel>(account); // assert accountModel.ShouldNotBeNull(); accountModel.ShouldSatisfyAllConditions( () => accountModel.AccountNumber.ShouldBe(account.AccountNumber), () => accountModel.AccountStatus.ShouldBe(account.AccountStatus.Name), () => accountModel.Id.ShouldBe(account.Id), () => accountModel.AccountBalance.ShouldBe(account.AccountBalance), () => accountModel.PendingBalance.ShouldBe(account.PendingBalance), () => accountModel.AvailableBalance.ShouldBe(account.AccountBalance + account.PendingBalance)); }
private static async Task <Account> CreateOneAccountWithOneMember(int accountId, int memberId, UserContext context) { var memberAccount = MemberDataBuilder.CreateMemberAccount(1, accountId, memberId); var member = MemberDataBuilder.CreateMember(1, new List <MemberAccount> { memberAccount }, null, null); var account = AccountDataBuilder.CreateAccount(1, new List <MemberAccount> { memberAccount }); await context.Accounts.AddAsync(account); await context.Members.AddAsync(member); await context.SaveChangesAsync(); return(account); }