/// <summary> /// Copies all the keys held in another collection into this collection /// </summary> /// <param name="keyCol">The other collection</param> public void Add(BOKeyCol keyCol) { foreach (IBOKey key in keyCol) { this.Add(key); } }
/// <summary> /// Creates a new collection of business object keys (BOKey) /// using the key definitions in this collection. /// </summary> /// <param name="lBOPropCol">The collection of properties</param> /// <returns>Returns a new BOKey collection object containing a mirror /// of this key definition collection</returns> public BOKeyCol CreateBOKeyCol(IBOPropCol lBOPropCol) { BOKeyCol lBOKeyCol = new BOKeyCol(); foreach (IKeyDef lKeyDef in this) { lBOKeyCol.Add(lKeyDef.CreateBOKey(lBOPropCol)); } return(lBOKeyCol); }
public void TestIndexer() { //---------------Set up test pack------------------- BOKeyCol col = new BOKeyCol(); col.Add(new BOKey(new KeyDef("anotherkey"))); BOKey boKey = new BOKey(new KeyDef("key")); col.Add(boKey); //---------------Execute Test ---------------------- IBOKey indexedKey = col["key"]; //---------------Test Result ----------------------- Assert.AreSame(boKey, indexedKey); }
public void TestIndexerWithNonExistingKey() { //---------------Set up test pack------------------- BOKeyCol col = new BOKeyCol(); //---------------Execute Test ---------------------- try { IBOKey key = col["invalidkey"]; Assert.Fail("Expected to throw an InvalidKeyException"); } //---------------Test Result ----------------------- catch (InvalidKeyException ex) { StringAssert.Contains("does not exist in the collection of keys", ex.Message); } }
public void TestAddDuplicates() { //---------------Set up test pack------------------- BOKeyCol col = new BOKeyCol(); IBOKey boKey = new BOKey(new KeyDef()); col.Add(boKey); //---------------Execute Test ---------------------- try { col.Add(boKey); Assert.Fail("Expected to throw an InvalidKeyException"); } //---------------Test Result ----------------------- catch (InvalidKeyException ex) { StringAssert.Contains("already exists in the collection", ex.Message); } }