public void TestCombine() { Xorshift prng = new Xorshift(); PerturbedAtomHashGenerator generator = new PerturbedAtomHashGenerator(new SeedGenerator( BasicAtomEncoder.AtomicNumber), new BasicAtomHashGenerator(new SeedGenerator( BasicAtomEncoder.AtomicNumber), prng, 8), prng, StereoEncoderFactory.Empty, new MinimumEquivalentCyclicSet(), AtomSuppression.Unsuppressed); long[][] perturbed = new long[][] { new long[] { 1, 2, 3, 4 }, new long[] { 1, 1, 1, 1 }, new long[] { 1, 2, 2, 4 }, new long[] { 2, 2, 2, 2 }, }; long _0 = 1 ^ 2 ^ 3 ^ 4; long _1 = 1 ^ prng.Next(1) ^ prng.Next(prng.Next(1)) ^ prng.Next(prng.Next(prng.Next(1))); long _2 = 1 ^ 2 ^ prng.Next(2) ^ 4; long _3 = 2 ^ prng.Next(2) ^ prng.Next(prng.Next(2)) ^ prng.Next(prng.Next(prng.Next(2))); long[] values = generator.Combine(perturbed); Assert.IsTrue(Compares.AreDeepEqual(new long[] { _0, _1, _2, _3 }, values)); }
public void TestGenerate() { IAtomContainer m1 = Cyclopentylcyclopentane(); IAtomContainer m2 = Decahydronaphthalene(); SeedGenerator seeding = new SeedGenerator(BasicAtomEncoder.AtomicNumber); Pseudorandom pseudorandom = new Xorshift(); IMoleculeHashGenerator basic = new BasicMoleculeHashGenerator(new BasicAtomHashGenerator(seeding, pseudorandom, 8)); IMoleculeHashGenerator perturb = new BasicMoleculeHashGenerator(new PerturbedAtomHashGenerator(seeding, new BasicAtomHashGenerator(seeding, pseudorandom, 8), pseudorandom, StereoEncoderFactory.Empty, new MinimumEquivalentCyclicSet(), AtomSuppression.Unsuppressed)); // basic encoding should say these are the same Assert.AreEqual(basic.Generate(m1), basic.Generate(m2)); // perturbed encoding should differentiate them Assert.AreNotEqual(perturb.Generate(m1), perturb.Generate(m2)); }
public void TestGenerate_Rotation() { var m_atomGenerator = new Mock <IAtomHashGenerator>(); var atomGenerator = m_atomGenerator.Object; Xorshift xorshift = new Xorshift(); var m_container = new Mock <IAtomContainer>(); var container = m_container.Object; IMoleculeHashGenerator generator = new BasicMoleculeHashGenerator(atomGenerator, new Xorshift()); m_atomGenerator.Setup(n => n.Generate(container)).Returns(new long[] { 5L, 5L, 5L, 5L }); long hashCode = generator.Generate(container); m_atomGenerator.Verify(n => n.Generate(container), Times.Exactly(1)); //VerifyNoMoreInteractions(atomGenerator, container); long expected = 2147483647L ^ 5L ^ xorshift.Next(5L) ^ xorshift.Next(xorshift.Next(5L)) ^ xorshift.Next(xorshift.Next(xorshift.Next(5L))); Assert.AreEqual(expected, hashCode); }