public virtual void TestIsEmpty() { IChemObjectSet <IAtomContainer> set = (IChemObjectSet <IAtomContainer>)NewChemObject(); Assert.IsTrue(set.IsEmpty(), "new container set should be empty"); set.Add(set.Builder.NewAtomContainer()); Assert.IsFalse(set.IsEmpty(), "container set with a single container should not be empty"); set.Clear(); Assert.IsTrue(set.IsEmpty(), "container set with all containers removed should be empty"); }
/// <summary> /// <para>Sorts the IAtomContainers in the given IAtomContainerSet by the following /// criteria with decreasing priority:</para> /// <list type="bullet"> /// <item>Compare atom count</item> /// <item>Compare molecular weight (heavy atoms only)</item> /// <item>Compare bond count</item> /// <item>Compare sum of bond orders (heavy atoms only)</item> /// </list> /// <para>If no difference can be found with the above criteria, the IAtomContainers are /// considered equal.</para> /// </summary> /// <param name="atomContainerSet">The collection of IAtomContainer objects</param> public static void Sort <T>(IChemObjectSet <T> atomContainerSet) where T : IAtomContainer { var atomContainerList = atomContainerSet.ToList(); atomContainerList.Sort(new AtomContainerComparator <T>()); atomContainerSet.Clear(); foreach (var anAtomContainerList in atomContainerList) { atomContainerSet.Add(anAtomContainerList); } }
public virtual void TestRemoveAll() { IChemObjectSet <T> som = (IChemObjectSet <T>)NewChemObject(); T ac1 = NewContainerObject(); T ac2 = NewContainerObject(); som.Add(ac1); som.Add(ac2); Assert.AreEqual(2, som.Count); som.Clear(); Assert.AreEqual(0, som.Count); }