Esempio n. 1
0
File: Pattern.cs Progetto: qize/NCDK
 internal Mappings Filter(Mappings mappings, IAtomContainer query, IAtomContainer target)
 {
     // apply required post-match filters
     if (hasStereo)
     {
         mappings = hasQueryStereo
             ? mappings.Filter(new QueryStereoFilter(query, target).Apply)
             : mappings.Filter(new StereoMatch(query, target).Apply);
     }
     if (hasComponentGrouping)
     {
         mappings = mappings.Filter(new ComponentFilter(query, target).Apply);
     }
     if (hasReactionMap)
     {
         mappings = mappings.Filter(new AtomMapFilter(query, target).Apply);
     }
     return(mappings);
 }
Esempio n. 2
0
        public void Filter()
        {
            var m_iterable = new Mock <IEnumerable <int[]> >(); var iterable = m_iterable.Object;
            var m_iterator = new Mock <IEnumerator <int[]> >(); var iterator = m_iterator.Object;

            m_iterable.Setup(n => n.GetEnumerator()).Returns(iterator);

            int[] p1 = { 0, 1, 2 };
            int[] p2 = { 0, 2, 1 };
            int[] p3 = { 0, 3, 4 };
            int[] p4 = { 0, 4, 3 };

            m_iterator.SetupSequence(n => n.MoveNext()).Returns(true).Returns(true).Returns(true).Returns(true).Returns(false);
            m_iterator.SetupSequence(n => n.Current).Returns(p1).Returns(p2).Returns(p3).Returns(p4);

            Mappings ms = new Mappings(new Mock <IAtomContainer>().Object, new Mock <IAtomContainer>().Object, iterable);

            bool f(int[] n)
            {
                if (n == p1)
                {
                    return(false);
                }
                if (n == p2)
                {
                    return(true);
                }
                if (n == p3)
                {
                    return(false);
                }
                if (n == p4)
                {
                    return(true);
                }
                throw new InvalidOperationException();
            }

            Assert.IsTrue(Compares.AreDeepEqual(new int[][] { p2, p4 }, ms.Filter(f).ToArray()));
        }