예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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>());
        }
예제 #4
0
        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);
        }
예제 #5
0
        /// <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);
            }
        }
예제 #6
0
 public void TestCreate_Null2()
 {
     ConjugatedAtomEncoder.Create(new Mock <IAtomEncoder>().Object, null);
 }
예제 #7
0
 public void TestCreate_Null()
 {
     ConjugatedAtomEncoder.Create(null, new IAtomEncoder[0]);
 }