public void TestMap_Map_Map() { IChemObjectBuilder builder = ChemObjectBuilder.Instance; IAtom c1 = builder.NewAtom("C"); IAtom o2 = builder.NewAtom("O"); IAtom n3 = builder.NewAtom("N"); IAtom c4 = builder.NewAtom("C"); IAtom h5 = builder.NewAtom("H"); // new stereo element ITetrahedralChirality original = new TetrahedralChirality(c1, new IAtom[] { o2, n3, c4, h5 }, TetrahedralStereo.Clockwise); // clone the atoms and place in a map var mapping = new CDKObjectMap(); IAtom c1clone = (IAtom)c1.Clone(); mapping.Set(c1, c1clone); IAtom o2clone = (IAtom)o2.Clone(); mapping.Set(o2, o2clone); IAtom n3clone = (IAtom)n3.Clone(); mapping.Set(n3, n3clone); IAtom c4clone = (IAtom)c4.Clone(); mapping.Set(c4, c4clone); IAtom h5clone = (IAtom)h5.Clone(); mapping.Set(h5, h5clone); // map the existing element a new element ITetrahedralChirality mapped = (ITetrahedralChirality)original.Clone(mapping); Assert.AreNotSame(original.ChiralAtom, mapped.ChiralAtom, "mapped chiral atom was the same as the original"); Assert.AreSame(c1clone, mapped.ChiralAtom, "mapped chiral atom was not the clone"); var originalLigands = original.Ligands; var mappedLigands = mapped.Ligands; Assert.AreNotSame(originalLigands[0], mappedLigands[0], "first ligand was the same as the original"); Assert.AreSame(o2clone, mappedLigands[0], "first mapped ligand was not the clone"); Assert.AreNotSame(originalLigands[1], mappedLigands[1], "second ligand was the same as the original"); Assert.AreSame(n3clone, mappedLigands[1], "second mapped ligand was not the clone"); Assert.AreNotSame(originalLigands[2], mappedLigands[2], "third ligand was the same as the original"); Assert.AreSame(c4clone, mappedLigands[2], "third mapped ligand was not the clone"); Assert.AreNotSame(originalLigands[3], mappedLigands[3], "forth ligand was te same as the original"); Assert.AreSame(h5clone, mappedLigands[3], "forth mapped ligand was not the clone"); Assert.AreEqual(original.Stereo, mapped.Stereo, "stereo was not mapped"); }
public void TestMap_Null_Map() { IChemObjectBuilder builder = ChemObjectBuilder.Instance; IAtom c1 = builder.NewAtom("C"); IAtom o2 = builder.NewAtom("O"); IAtom n3 = builder.NewAtom("N"); IAtom c4 = builder.NewAtom("C"); IAtom h5 = builder.NewAtom("H"); // new stereo element ITetrahedralChirality original = new TetrahedralChirality(c1, new IAtom[] { o2, n3, c4, h5 }, TetrahedralStereo.Clockwise); // map the existing element a new element ITetrahedralChirality mapped = (ITetrahedralChirality)original.Clone(null); }
public void TestMap_Map_Map_EmptyMapping() { IChemObjectBuilder builder = ChemObjectBuilder.Instance; IAtom c1 = builder.NewAtom("C"); IAtom o2 = builder.NewAtom("O"); IAtom n3 = builder.NewAtom("N"); IAtom c4 = builder.NewAtom("C"); IAtom h5 = builder.NewAtom("H"); // new stereo element ITetrahedralChirality original = new TetrahedralChirality(c1, new IAtom[] { o2, n3, c4, h5 }, TetrahedralStereo.Clockwise); // map the existing element a new element - should through an IllegalArgumentException var map = new CDKObjectMap(); ITetrahedralChirality mapped = (ITetrahedralChirality)original.Clone(map); Assert.AreSame(original.ChiralAtom, mapped.ChiralAtom); }