public void ShouldBeAbleToFindTwoClientAccountsShareACommonAccount() { var account1 = new Account(new AccountId(12341234), new ClientId("ABC123")); var account2 = new Account(new AccountId(12341235), new ClientId("ABC123")); var account3 = new Account(new AccountId(12341236), new ClientId("ABC123")); var account4 = new Account(new AccountId(12341237), new ClientId("ABC123")); var clientAccounts1 = new ClientAccounts(); clientAccounts1.Add(account1); clientAccounts1.Add(account2); var clientAccounts2 = new ClientAccounts(); clientAccounts2.Add(account1); clientAccounts2.Add(account3); var clientAccounts3 = new ClientAccounts(); clientAccounts3.Add(account3); clientAccounts3.Add(account4); Assert.IsTrue(clientAccounts1.SharesAccountWith(clientAccounts2)); Assert.IsFalse(clientAccounts1.SharesAccountWith(clientAccounts3)); }
public void ShouldBeAbleToFindIfTwoStructuresHaveSharedAccounts() { var clientId = new ClientId("ABC123"); var account1 = new Account(new AccountId(12341234), clientId); var account2 = new Account(new AccountId(12341235), clientId); var account3 = new Account(new AccountId(12341236), clientId); var account4 = new Account(new AccountId(12341237), clientId); var clientAccounts1 = new ClientAccounts(); clientAccounts1.Add(account1); clientAccounts1.Add(account2); var allocations = new List <Allocation> { new Allocation(new Account(new AccountId(54321439), clientId), 100) }; var structure1 = new Structure(clientAccounts1, allocations, null, null); var clientAccounts2 = new ClientAccounts(); clientAccounts2.Add(account1); clientAccounts2.Add(account3); var structure2 = new Structure(clientAccounts2, allocations, null, null); var clientAccounts3 = new ClientAccounts(); clientAccounts3.Add(account4); clientAccounts3.Add(account3); var structure3 = new Structure(clientAccounts3, allocations, null, null); Assert.IsTrue(structure1.SharesASourceAccountWith(structure2)); Assert.IsFalse(structure1.SharesASourceAccountWith(structure3)); }
public void DeleteClientAccount(Guid id) { if (ClientAccounts.ContainsKey(id)) { ClientAccounts.Remove(id); } }
public void ShouldNotBeAbleToCreateClientStructuresWithTwoRepeatingAccounts() { var clientId = new ClientId("ABC123"); var account1 = new Account(new AccountId(12341234), clientId); var account2 = new Account(new AccountId(12341235), clientId); var account3 = new Account(new AccountId(12341236), clientId); var clientAccounts1 = new ClientAccounts(); clientAccounts1.Add(account1); clientAccounts1.Add(account2); var clientAccounts2 = new ClientAccounts(); clientAccounts2.Add(account1); clientAccounts2.Add(account3); var structure1 = new Structure(clientAccounts1, getAllocation(), null, null); var structure2 = new Structure(clientAccounts2, getAllocation(), null, null); var structures = new Structures(); structures.Add(structure1); Assert.Throws <ArgumentException>(() => structures.Add(structure2)); }
private async Task prepareTestData() { ApiConsumer registerConsumer = new ApiConsumer(new ConfigBuilder("BlueApi")); this.TestClient = await registerConsumer.RegisterNewUser(); await ClientAccounts.FillWalletWithAsset(TestClient.Account.Id, Constants.BALANCES_ASSET_ID, Constants.BALANCES_ASSET_AMOUNT); }
public async Task CreatePledgeClientAndApiConsumer(string purpose) { ApiConsumer consumer = new ApiConsumer(_blueApiAppSettings); await consumer.RegisterNewUser(); AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(consumer.ClientInfo.Account.Id)); PledgeApiConsumers.Add(purpose, consumer); }
public void ShouldCreateClientAccountsFromAccountCollection() { var clientId1 = new ClientId("ABC123"); var clientAccounts = new ClientAccounts(new List <Account> { new Account(new AccountId(12341234), clientId1), new Account(new AccountId(12341235), clientId1) }); Assert.AreEqual(2, clientAccounts.Count); }
public void ShouldNotBeAbleToCreateAStructureWithLessThanTwoSourceAccounts() { var clientId = new ClientId("ABC123"); var account1 = new Account(new AccountId(12341234), clientId); var clientAccounts = new ClientAccounts(); clientAccounts.Add(account1); Assert.Throws <ArgumentException>(() => new Structure(clientAccounts, null, null, null)); }
public ClientAccount AddClientAccount(string clientName) { var id = Guid.NewGuid(); var clientAccount = new ClientAccount().CreateAccount(id, clientName); ClientAccounts.Add(id, clientAccount); return(clientAccount); }
public void ShouldNotBeAbleToCreatAStructureWithAccountsFromTwoDifferentClients() { var clientId1 = new ClientId("ABC123"); var clientId2 = new ClientId("ABC124"); var account1 = new Account(new AccountId(12341234), clientId1); var account2 = new Account(new AccountId(12341235), clientId2); var clientAccounts = new ClientAccounts(); clientAccounts.Add(account1); Assert.Throws <ArgumentException>(() => clientAccounts.Add(account2)); }
public ClientAccount UpdateClientAccount(Guid id, string clientName) { if (!ClientAccounts.ContainsKey(id)) { return(null); } var clientAccount = ClientAccounts[id]; clientAccount.ClientName = clientName; return(clientAccount); }
public void ShouldCalculateNetBalance() { var account1 = new Account(new AccountId(12341234), new ClientId("ABC123")); var account2 = new Account(new AccountId(12341235), new ClientId("ABC123")); account1.Balance = 1000.0; account2.Balance = -500.0; var clientAccounts = new ClientAccounts(); clientAccounts.Add(account1); clientAccounts.Add(account2); Assert.AreEqual(500.0, clientAccounts.NetBalance()); }
public UserProfile AddNewUserProfileToAccount(Guid userAccountId, Guid clientId, string emailAddress, List <AwardItem> awards = null) { if (!UserAccounts.ContainsKey(userAccountId) || !ClientAccounts.ContainsKey(clientId)) { return(null); } var clientAccount = ClientAccounts[clientId]; var newProfile = new UserProfile().CreateUserProfile(Guid.NewGuid(), emailAddress, clientAccount, awards); UserAccounts[userAccountId].AddProfile(newProfile); return(newProfile); }
public void ShouldBeAbleAddAStructure() { var clientId = new ClientId("ABC123"); var account1 = new Account(new AccountId(12341234), clientId); var account2 = new Account(new AccountId(12341235), clientId); var clientAccounts = new ClientAccounts(); clientAccounts.Add(account1); clientAccounts.Add(account2); var structure = new Structure(clientAccounts, getAllocation(), null, null); var client = new Client(clientId, clientAccounts); client.AddStructure(structure); Assert.IsTrue(client.Contains(structure)); }
private static Structure GetTestStructure(double balance1, double balance2, List <Allocation> allocations, InterestRates interestRates, PaymentInstructionService paymentInstructionService) { var clientId = new ClientId("ABC123"); var account1 = new Account(new AccountId(12341234), clientId); var account2 = new Account(new AccountId(12341235), clientId); account1.Balance = balance1; account2.Balance = balance2; var clientAccounts = new ClientAccounts(); clientAccounts.Add(account1); clientAccounts.Add(account2); return(new Structure(clientAccounts, allocations, interestRates, paymentInstructionService)); }
public UserProfile UpdateUserProfile(Guid profileId, Guid clientId, string emailAddress, List <AwardItem> awards = null) { if (!ClientAccounts.ContainsKey(clientId) || !UserProfiles.Any(up => up.Id == profileId)) { return(null); } var clientAccount = ClientAccounts[clientId]; var updatedUserProfile = new UserProfile().CreateUserProfile(profileId, emailAddress, clientAccount, awards); var currentProfile = UserProfiles.Single(up => up.Id == profileId); currentProfile.UpdateUserProfile(updatedUserProfile); return(currentProfile); }
private async Task <List <ApiConsumer> > RegisterNUsers(int n) { List <ApiConsumer> result = new List <ApiConsumer>(); for (int i = 0; i < n; i++) { ApiConsumer consumer = new ApiConsumer(_blueApiAppSettings); await consumer.RegisterNewUser(); AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(consumer.ClientInfo.Account.Id)); result.Add(consumer); } return(result); }
public async Task CreateTestPartnerClient() { await ClientAccountConsumer.RegisterNewUser( new ClientRegisterDTO { Email = Helpers.RandomString(8) + GlobalConstants.AutoTestEmail, FullName = Helpers.RandomString(5) + " " + Helpers.RandomString(8), ContactPhone = Helpers.Random.Next(1000000, 9999999).ToString(), Password = Helpers.RandomString(10), Hint = Helpers.RandomString(3), PartnerId = _blueApiAppSettings.TestPartnerId // "NewTestPartner" } ); AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(ClientAccountConsumer.ClientInfo.Account.Id)); }
private async Task PrepareTestData() { var TestClient = await Consumer.RegisterNewUser(); TestClientId = TestClient.Account.Id; var walletsFromDB = this.WalletRepository.GetAllAsync(w => w.ClientId == TestClientId && w.State != "deleted"); var operationsFromDB = this.OperationsRepository.GetAllAsync(o => o.PartitionKey == OperationsEntity.GeneratePartitionKey() && o.ClientId.ToString() == TestClientId); this.TestAssetId = Constants.TestAssetId; this.AssetPrecission = 2; this.AllWalletsFromDb = (await walletsFromDB).Cast <WalletEntity>().ToList(); this.TestWallet = await CreateTestWallet(); //fill wallet with funds await MEConsumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestWallet.Id, Constants.TestAssetId, 50.0); this.TestWalletWithBalanceId = TestWallet.Id; this.TestWalletDelete = await CreateTestWallet(); this.TestWalletAccount = await AccountRepository.TryGetAsync(TestWallet.Id) as AccountEntity; this.TestWalletOperations = await CreateTestWallet(); this.TestWalletRegenerateKey = await CreateTestWallet(true); this.TestOperation = await CreateTestOperation(); this.TestOperationCancel = await CreateTestOperation(); this.TestOperationCreateDetails = await CreateTestOperation(); this.TestOperationRegisterDetails = await CreateTestOperation(); this.ClientInfoConsumer = new ApiConsumer(_apiV2Settings); await this.ClientInfoConsumer.RegisterNewUser(); AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(ClientInfoConsumer.ClientInfo.Account.Id)); // set the id to the default one in case it has been changed by any test BaseAssetDTO body = new BaseAssetDTO(this.TestAssetId); var response = await Consumer.ExecuteRequest(ApiPaths.ASSETS_BASEASSET_PATH, Helpers.EmptyDictionary, JsonUtils.SerializeObject(body), Method.POST); }
public async Task CreateLykkeBluePartnerClientAndApiConsumer() { var consumer = new ApiConsumer(_configBuilder); await consumer.RegisterNewUser( new ClientRegisterDTO { Email = Helpers.RandomString(8) + GlobalConstants.AutoTestEmail, FullName = Helpers.RandomString(5) + " " + Helpers.RandomString(8), ContactPhone = Helpers.Random.Next(1000000, 9999999).ToString(), Password = Helpers.RandomString(10), Hint = Helpers.RandomString(3), PartnerId = _configBuilder.Config["LykkeBluePartnerId"] // "Lykke.blue" } ); AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(consumer.ClientInfo.Account.Id)); }
private async Task prepareTestData() { ConfigBuilder apiv2Config = new ConfigBuilder("ApiV2"); ApiConsumer registerConsumer1 = new ApiConsumer(apiv2Config); ApiConsumer registerConsumer2 = new ApiConsumer(apiv2Config); var registerTestAccount1 = registerConsumer1.RegisterNewUser(); var registerTestAccount2 = registerConsumer2.RegisterNewUser(); TestAsset1 = Constants.TestAsset1; TestAsset2 = Constants.TestAsset2; TestAccountId1 = (await registerTestAccount1)?.Account.Id; TestAccountId2 = (await registerTestAccount2)?.Account.Id; AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(TestAccountId1)); AddOneTimeCleanupAction(async() => await ClientAccounts.DeleteClientAccount(TestAccountId2)); //give test clients some cash to work with List <Task> giveCashTasks = new List <Task>() { Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId1, TestAsset1, Constants.InitialAssetAmmount), Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId1, TestAsset2, Constants.InitialAssetAmmount), Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId2, TestAsset1, Constants.InitialAssetAmmount), Consumer.Client.UpdateBalanceAsync(Guid.NewGuid().ToString(), TestAccountId2, TestAsset2, Constants.InitialAssetAmmount) }; if (!Int32.TryParse(_configBuilder.Config["AssetPrecission"], out AssetPrecission)) { AssetPrecission = 2; } this.TestAssetPair = (AssetPairEntity)Task.Run(async() => { return(await this.AssetPairsRepository.TryGetAsync(TestAsset1 + TestAsset2)); }).Result; await Task.WhenAll(giveCashTasks); }
public ClientAccount GetClientAccountById(Guid id) { return(ClientAccounts.ContainsKey(id) ? ClientAccounts[id] : null); }