public void AddHashPairTest() { //查看在BeginEdit前进行调用是否会抛出异常; var ex = Assert.ThrowsException <InvalidOperationException>(() => { AddHashPairTestCore(); }); Assert.IsNotNull(ex); _hashSet.BeginEdit(); _hashSet.Clear(); AddHashPairTestCore(); _hashSet.EndEdit(); _hashSet.BeginOpen(); var allPairs = _hashSet.GetAllHashPairs(); Assert.AreEqual(allPairs.Count(), 1); Assert.IsNotNull(allPairs.FirstOrDefault(p => p.Name == TestName)); _hashSet.EndOpen(); }