public static void TestGetListenerCount(IChemObject chemObject) { ChemObjectListener listener = new ChemObjectListener(); chemObject.Listeners.Add(listener); Assert.AreEqual(0, chemObject.Listeners.Count); }
public static void TestSetAtoms_RemoveListener(IChemObject newChemObject) { IAtomContainer container = (IAtomContainer)newChemObject; IAtom[] atoms = new IAtom[4]; atoms[0] = container.Builder.NewAtom("C"); atoms[1] = container.Builder.NewAtom("C"); atoms[2] = container.Builder.NewAtom("C"); atoms[3] = container.Builder.NewAtom("O"); container.SetAtoms(atoms); // if an atom changes, the atomcontainer will throw a change event too ChemObjectListener listener = new ChemObjectListener(); container.Listeners.Add(listener); Assert.IsFalse(listener.Changed); // ok, change the atom, and make sure we do get an event atoms[0].AtomTypeName = "C.sp2"; Assert.IsFalse(listener.Changed); // reset the listener, overwrite the atoms, and change an old atom. // if all is well, we should not get a change event this time listener.Reset(); Assert.IsFalse(listener.Changed); // make sure the reset worked container.SetAtoms(Array.Empty <IAtom>()); atoms[1].AtomTypeName = "C.sp2"; // make a change to an old atom Assert.IsFalse(listener.Changed); // but no change event should happen }
public static void TestNotifyChanged_IChemObjectChangeEvent(IChemObject chemObject) { ChemObjectListener listener = new ChemObjectListener(); chemObject.Listeners.Add(listener); chemObject.Id = "Changed"; Assert.IsNull(listener.Event); }
public static void TestNotifyChanged(IChemObject chemObject) { ChemObjectListener listener = new ChemObjectListener(); chemObject.Listeners.Add(listener); chemObject.Id = "Changed"; Assert.IsFalse(listener.Changed); }
public static void TestNotifyChanged_SetProperty(IChemObject chemObject) { ChemObjectListener listener = new ChemObjectListener(); chemObject.Listeners.Add(listener); chemObject.SetProperty("Changed", "Yes"); Assert.IsFalse(listener.Changed); }
public static void TestNotifyChanged_SetFlags(IChemObject chemObject) { ChemObjectListener listener = new ChemObjectListener(); chemObject.Listeners.Add(listener); Assert.IsFalse(listener.Changed); chemObject.IsVisited = true; Assert.IsFalse(listener.Changed); }
public static void TestSetNotification_true(IChemObject chemObject) { ChemObjectListener listener = new ChemObjectListener(); chemObject.Listeners.Add(listener); chemObject.Notification = true; chemObject.Id = "Changed"; Assert.IsFalse(listener.Changed); }
public static void TestClone_ChemObjectListeners(IChemObject chemObject) { ChemObjectListener listener = new ChemObjectListener(); chemObject.Listeners.Add(listener); IChemObject chemObject2 = (IChemObject)chemObject.Clone(); // test lack of cloning of listeners Assert.AreEqual(0, chemObject.Listeners.Count); Assert.AreEqual(0, chemObject2.Listeners.Count); }
public override void TestStateChanged_EventPropagation_RingSet() { ChemObjectListener listener = new ChemObjectListener(); IChemModel chemObject = (IChemModel)NewChemObject(); chemObject.Listeners.Add(listener); IRingSet ringSet = chemObject.Builder.NewRingSet(); chemObject.RingSet = ringSet; Assert.IsFalse(listener.Changed); // reset the listener listener.Reset(); Assert.IsFalse(listener.Changed); // changing the set should trigger a change event in the IChemModel ringSet.Add(chemObject.Builder.NewRing()); Assert.IsFalse(listener.Changed); }
public override void TestStateChanged_EventPropagation_AtomContainerSet() { ChemObjectListener listener = new ChemObjectListener(); IChemModel chemObject = (IChemModel)NewChemObject(); chemObject.Listeners.Add(listener); var molSet = chemObject.Builder.NewAtomContainerSet(); chemObject.MoleculeSet = molSet; Assert.IsFalse(listener.Changed); // reset the listener listener.Reset(); Assert.IsFalse(listener.Changed); // changing the set should trigger a change event in the IChemModel molSet.Add(chemObject.Builder.NewAtomContainer()); Assert.IsFalse(listener.Changed); }
public override void TestStateChanged_EventPropagation_Crystal() { ChemObjectListener listener = new ChemObjectListener(); IChemModel chemObject = (IChemModel)NewChemObject(); chemObject.Listeners.Add(listener); ICrystal crystal = chemObject.Builder.NewCrystal(); chemObject.Crystal = crystal; Assert.IsFalse(listener.Changed); // reset the listener listener.Reset(); Assert.IsFalse(listener.Changed); // changing the set should trigger a change event in the IChemModel crystal.Add(chemObject.Builder.NewAtomContainer()); Assert.IsFalse(listener.Changed); }
public static void TestStateChanged_IChemObjectChangeEvent(IChemObject chemObject) { ChemObjectListener listener = new ChemObjectListener(); chemObject.Listeners.Add(listener); chemObject.Id = "Changed"; Assert.IsFalse(listener.Changed); listener.Reset(); Assert.IsFalse(listener.Changed); chemObject.SetProperty("Changed", "Again"); Assert.IsFalse(listener.Changed); listener.Reset(); Assert.IsFalse(listener.Changed); chemObject.IsPlaced = true; Assert.IsFalse(listener.Changed); }
public override void TestStateChanged_ButNotAfterRemoval_RingSet() { ChemObjectListener listener = new ChemObjectListener(); IChemModel chemObject = (IChemModel)NewChemObject(); chemObject.Listeners.Add(listener); IRingSet ringSet = chemObject.Builder.NewRingSet(); chemObject.RingSet = ringSet; Assert.IsFalse(listener.Changed); // remove the set from the IChemModel chemObject.RingSet = null; // reset the listener listener.Reset(); Assert.IsFalse(listener.Changed); // changing the set must *not* trigger a change event in the IChemModel ringSet.Add(chemObject.Builder.NewRing()); Assert.IsFalse(listener.Changed); }
public override void TestStateChanged_ButNotAfterRemoval_Crystal() { ChemObjectListener listener = new ChemObjectListener(); IChemModel chemObject = (IChemModel)NewChemObject(); chemObject.Listeners.Add(listener); ICrystal crystal = chemObject.Builder.NewCrystal(); chemObject.Crystal = crystal; Assert.IsFalse(listener.Changed); // remove the set from the IChemModel chemObject.Crystal = null; // reset the listener listener.Reset(); Assert.IsFalse(listener.Changed); // changing the set must *not* trigger a change event in the IChemModel crystal.Add(chemObject.Builder.NewAtomContainer()); Assert.IsFalse(listener.Changed); }