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 structure1 = new Structure(clientAccounts1); var clientAccounts2 = new ClientAccounts(); clientAccounts2.Add(account1); clientAccounts2.Add(account3); var structure2 = new Structure(clientAccounts2); var clientAccounts3 = new ClientAccounts(); clientAccounts3.Add(account4); clientAccounts3.Add(account3); var structure3 = new Structure(clientAccounts3); Assert.IsTrue(structure1.SharesASourceAccountWith(structure2)); Assert.IsFalse(structure1.SharesASourceAccountWith(structure3)); }
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 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); var client = new Client(clientId, clientAccounts); client.AddStructure(structure); Assert.IsTrue(client.Contains(structure)); }
public void ShouldBeAbleToAddAStructure() { 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 structures = new Structures(); structures.Add(structure); Assert.True(structures.Contains(structure)); }
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); var structure2 = new Structure(clientAccounts2); var structures = new Structures(); structures.Add(structure1); Assert.Throws<ArgumentException>(() => structures.Add(structure2)); }
public bool Contains(Structure structure) { return structures.Contains(structure); }
public void AddStructure(Structure structure) { structures.Add(structure); }
public bool SharesASourceAccountWith(Structure newStructure) { return sourceClientAccounts.SharesAccountWith(newStructure.sourceClientAccounts); }
public bool Contains(Structure structure) { return(structures.Contains(structure)); }
private bool HasOverlappingAccount(Structure newStructure) { return structureSet.Any(structure => structure.SharesASourceAccountWith(newStructure)); }
public void Add(Structure structure) { if (HasOverlappingAccount(structure)) throw new ArgumentException("Cannot add two structure containing same accounts."); structureSet.Add(structure); }
public bool SharesASourceAccountWith(Structure newStructure) { return(sourceClientAccounts.SharesAccountWith(newStructure.sourceClientAccounts)); }