示例#1
0
        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));
        }
示例#2
0
        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));
        }
示例#3
0
 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));
 }
示例#4
0
        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));
        }
示例#5
0
        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));
        }
示例#6
0
文件: Client.cs 项目: habib/AnujBank
 public bool Contains(Structure structure)
 {
     return structures.Contains(structure);
 }
示例#7
0
文件: Client.cs 项目: habib/AnujBank
 public void AddStructure(Structure structure)
 {
     structures.Add(structure);
 }
示例#8
0
 public bool SharesASourceAccountWith(Structure newStructure)
 {
     return sourceClientAccounts.SharesAccountWith(newStructure.sourceClientAccounts);
 }
示例#9
0
文件: Client.cs 项目: habib/AnujBank
 public bool Contains(Structure structure)
 {
     return(structures.Contains(structure));
 }
示例#10
0
文件: Client.cs 项目: habib/AnujBank
 public void AddStructure(Structure structure)
 {
     structures.Add(structure);
 }
示例#11
0
 private bool HasOverlappingAccount(Structure newStructure)
 {
     return structureSet.Any(structure => structure.SharesASourceAccountWith(newStructure));
 }
示例#12
0
 public void Add(Structure structure)
 {
     if (HasOverlappingAccount(structure)) throw new ArgumentException("Cannot add two structure containing same accounts.");
     structureSet.Add(structure);
 }
示例#13
0
 public bool SharesASourceAccountWith(Structure newStructure)
 {
     return(sourceClientAccounts.SharesAccountWith(newStructure.sourceClientAccounts));
 }