public bool TryGetValue(out ReadOnlyCollection <AGraphElement> result, Object keyObject) { IComparable key; if (!IndexHelper.CheckObject(out key, keyObject)) { result = null; return(false); } if (ReadResource()) { AGraphElement element; var foundSth = _idx.TryGetValue(key, out element); result = foundSth ? new ReadOnlyCollection <AGraphElement>(new List <AGraphElement> { element }) : null; FinishReadResource(); return(foundSth); } throw new CollisionException(this); }
public void AddOrUpdate(Object keyObject, AGraphElement graphElement) { IComparable key; if (!IndexHelper.CheckObject(out key, keyObject)) { return; } if (WriteResource()) { List <AGraphElement> values; if (_idx.TryGetValue(key, out values)) { values.Add(graphElement); } else { values = new List <AGraphElement> { graphElement }; _idx.Add(key, values); } FinishWriteResource(); return; } throw new CollisionException(); }
public bool TryGetValue(out ReadOnlyCollection <AGraphElement> result, object keyObject) { String key; if (!IndexHelper.CheckObject(out key, keyObject)) { result = null; return(false); } if (ReadResource()) { try { List <AGraphElement> graphElements; var foundSth = _idx.TryGetValue(key, out graphElements); result = foundSth ? new ReadOnlyCollection <AGraphElement>(graphElements) : null; return(foundSth); } finally { FinishReadResource(); } } throw new CollisionException(this); }
// //You can use the following additional attributes as you write your tests: // //Use ClassInitialize to run code before running the first test in the class //[ClassInitialize()] //public static void MyClassInitialize(TestContext testContext) //{ //} // //Use ClassCleanup to run code after all tests in a class have run //[ClassCleanup()] //public static void MyClassCleanup() //{ //} // //Use TestInitialize to run code before running each test //[TestInitialize()] //public void MyTestInitialize() //{ //} // //Use TestCleanup to run code after each test has run //[TestCleanup()] //public void MyTestCleanup() //{ //} // #endregion /// <summary> ///A test for CheckObject ///</summary> public void CheckObjectUnitTestHelper <T>() where T : class { T result = null; // TODO: Initialize to an appropriate value T resultExpected = null; // TODO: Initialize to an appropriate value object obj = null; // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; actual = IndexHelper.CheckObject <T>(out result, obj); Assert.AreEqual(resultExpected, result); Assert.AreEqual(expected, actual); }
public bool TryRemoveKey(Object keyObject) { IComparable key; if (!IndexHelper.CheckObject(out key, keyObject)) { return(false); } if (WriteResource()) { var foundSth = _idx.Remove(key); FinishWriteResource(); return(foundSth); } throw new CollisionException(); }
public void AddOrUpdate(Object keyObject, AGraphElement graphElement) { IComparable key; if (!IndexHelper.CheckObject(out key, keyObject)) { return; } if (WriteResource()) { _idx[key] = graphElement; FinishWriteResource(); return; } throw new CollisionException(this); }
public bool TryRemoveKey(object keyObject) { String key; if (!IndexHelper.CheckObject(out key, keyObject)) { return(false); } if (WriteResource()) { try { var foundSth = _idx.Remove(key); return(foundSth); } finally { FinishWriteResource(); } } throw new CollisionException(this); }
public void AddOrUpdate(object keyObject, AGraphElement graphElement) { String key; if (!IndexHelper.CheckObject(out key, keyObject)) { return; } if (WriteResource()) { try { List <AGraphElement> values; if (_idx.TryGetValue(key, out values)) { values.Add(graphElement); } else { values = new List <AGraphElement> { graphElement }; _idx.Add(key, values); } } finally { FinishWriteResource(); } return; } throw new CollisionException(this); }