public void TestConstruction_Modification() { var m_a = new Mock <IAtomEncoder>(); var a = m_a.Object; var m_b = new Mock <IAtomEncoder>(); var b = m_b.Object; var m_c = new Mock <IAtomEncoder>(); var c = m_c.Object; var m_atom = new Mock <IAtom>(); var atom = m_atom.Object; var m_container = new Mock <IAtomContainer>(); var container = m_container.Object; var encoders = new List <IAtomEncoder>(); encoders.Add(a); encoders.Add(b); encoders.Add(c); IAtomEncoder encoder = new ConjugatedAtomEncoder(encoders); encoders.RemoveAt(2); // removing b should not affect the new encoder encoder.Encode(atom, container); // TODO: Moq does not support order feature. //InOrder order = InOrder(a, b, c); //order.m_a.Verify(n => n.Encode(atom, container), Times.Exactly(1)); //order.m_b.Verify(n => n.Encode(atom, container), Times.Exactly(1)); //order.m_c.Verify(n => n.Encode(atom, container), Times.Exactly(1)); //VerifyNoMoreInteractions(a, b, c, atom, container); }
public void TestEncode_Single() { var m_a = new Mock <IAtomEncoder>(); var a = m_a.Object; var m_atom = new Mock <IAtom>(); var atom = m_atom.Object; var m_container = new Mock <IAtomContainer>(); var container = m_container.Object; IAtomEncoder encoder = new ConjugatedAtomEncoder(new[] { a }); encoder.Encode(atom, container); m_a.Verify(n => n.Encode(atom, container), Times.Exactly(1)); //VerifyNoMoreInteractions(a, atom, container); }
internal static IList <IAtomEncoder> GetEncoders(ConjugatedAtomEncoder conjugated) { var field = conjugated.GetType().GetField("encoders", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); if (field == null) { Console.Error.WriteLine("Field 'encoders' is not found."); goto Exit; } return((IList <IAtomEncoder>)field.GetValue(conjugated)); Exit: return(new List <IAtomEncoder>()); }
public void TestEncode() { var m_a = new Mock <IAtomEncoder>(); var a = m_a.Object; var m_b = new Mock <IAtomEncoder>(); var b = m_b.Object; var m_c = new Mock <IAtomEncoder>(); var c = m_c.Object; var m_atom = new Mock <IAtom>(); var atom = m_atom.Object; var m_container = new Mock <IAtomContainer>(); var container = m_container.Object; IAtomEncoder encoder = new ConjugatedAtomEncoder(new[] { a, b, c, }); encoder.Encode(atom, container); //InOrder order = InOrder(a, b, c); //order.m_a.Verify(n => n.Encode(atom, container), Times.Exactly(1)); //order.m_b.Verify(n => n.Encode(atom, container), Times.Exactly(1)); //order.m_c.Verify(n => n.Encode(atom, container), Times.Exactly(1)); //VerifyNoMoreInteractions(a, b, c, atom, container); }
/// <summary> /// Given the current configuration create an <see cref="IAtomHashGenerator"/>. /// </summary> /// <returns>instance of the generator</returns> /// <exception cref="ArgumentException">no depth or encoders were configured</exception> public IAtomHashGenerator Atomic() { if (depth < 0) { throw new ArgumentException("no depth specified, use .Depth(int)"); } List <IAtomEncoder> encoders = new List <IAtomEncoder>(); // set is ordered encoders.AddRange(encoderSet); encoders.AddRange(this.customEncoders); // check if suppression of atoms is wanted - if not use a default value // we also use the 'Basic' generator (see below) bool suppress = suppression != AtomSuppression.Unsuppressed; IAtomEncoder encoder = new ConjugatedAtomEncoder(encoders); SeedGenerator seeds = new SeedGenerator(encoder, suppression); AbstractAtomHashGenerator simple = suppress ? (AbstractAtomHashGenerator) new SuppressedAtomHashGenerator(seeds, new Xorshift(), MakeStereoEncoderFactory(), suppression, depth) : (AbstractAtomHashGenerator) new BasicAtomHashGenerator(seeds, new Xorshift(), MakeStereoEncoderFactory(), depth); // if there is a finder for checking equivalent vertices then the user // wants to 'perturb' the hashed if (equivSetFinder != null) { return(new PerturbedAtomHashGenerator(seeds, simple, new Xorshift(), MakeStereoEncoderFactory(), equivSetFinder, suppression)); } else { // no equivalence set finder - just use the simple hash return(simple); } }
public void TestCreate_Null2() { ConjugatedAtomEncoder.Create(new Mock <IAtomEncoder>().Object, null); }
public void TestCreate_Null() { ConjugatedAtomEncoder.Create(null, new IAtomEncoder[0]); }