public void TestIsolatedRingFragments()
        {
            var n         = bicyclo.Atoms.Count;
            var fragments = new RingSearch(bicyclo).IsolatedRingFragments();

            Assert.IsTrue(fragments.Count() == 0);
        }
示例#2
0
        public void TestFusedRingFragments()
        {
            var mock_cyclicSearch = new Mock <ICyclicVertexSearch>();
            var mock_container    = new Mock <IAtomContainer>();
            var mock_builder      = new Mock <IChemObjectBuilder>();
            var mock_atom         = new Mock <IAtom>();

            RingSearch ringSearch = new RingSearch(mock_container.Object, mock_cyclicSearch.Object);

            mock_cyclicSearch.Setup(n => n.Fused()).Returns(new int[][] { new[] { 0, 1 }, new[] { 2 } });
            mock_container.Setup(n => n.Builder).Returns(mock_builder.Object);
            mock_builder.Setup(n => n.NewAtomContainer(It.IsAny <IEnumerable <IAtom> >(), It.IsAny <IEnumerable <IBond> >())).Returns(new Mock <IAtomContainer>().Object);
            mock_container.Setup(n => n.Bonds).Returns(new List <IBond>());
            mock_container.Setup(n => n.Atoms[It.IsAny <int>()]).Returns(new Mock <IAtom>().Object);

            ringSearch.FusedRingFragments().ToReadOnlyList();

            mock_cyclicSearch.Verify(n => n.Fused(), Times.Once());

            // atoms were accessed
            mock_container.Verify(n => n.Atoms[0], Times.Once());
            mock_container.Verify(n => n.Atoms[1], Times.Once());
            mock_container.Verify(n => n.Atoms[2], Times.Once());

            // builder was invoked
            mock_builder.Verify(n => n.NewAtomContainer(It.IsAny <IEnumerable <IAtom> >(), It.IsAny <IEnumerable <IBond> >()), Times.Exactly(2));
        }
示例#3
0
        public void TestFusedRingFragments()
        {
            var search = new RingSearch(spiro);
            var fused  = search.FusedRingFragments();

            Assert.AreEqual(0, fused.Count());
        }
示例#4
0
        public void TestRingFragments()
        {
            var mock_cyclicSearch = new Mock <ICyclicVertexSearch>();
            var mock_container    = new Mock <IAtomContainer>();
            var mock_builder      = new Mock <IChemObjectBuilder>();
            var mock_atom         = new Mock <IAtom>();

            RingSearch ringSearch = new RingSearch(mock_container.Object, mock_cyclicSearch.Object);

            mock_cyclicSearch.Setup(n => n.Cyclic()).Returns(new int[] { 0, 1, 2 });
            mock_cyclicSearch.Setup(n => n.Isolated()).Returns(new int[][] { new[] { 0, 1, 2 } });
            mock_cyclicSearch.Setup(n => n.Fused()).Returns(Array.Empty <int[]>());
            mock_container.Setup(n => n.Atoms.Count).Returns(3);
            mock_builder.Setup(n => n.NewAtomContainer(It.IsAny <IEnumerable <IAtom> >(), It.IsAny <IEnumerable <IBond> >())).Returns(new Mock <IAtomContainer>().Object);
            mock_container.Setup(n => n.Builder).Returns(mock_builder.Object);
            mock_container.Setup(n => n.Bonds).Returns(new List <IBond>());

            ringSearch.RingFragments();

            mock_cyclicSearch.Verify(n => n.Cyclic(), Times.Once());

            // atoms were accessed
            mock_container.Verify(n => n.Atoms[0], Times.Once());
            mock_container.Verify(n => n.Atoms[1], Times.Once());
            mock_container.Verify(n => n.Atoms[2], Times.Once());

            // builder was invoked
            mock_builder.Verify(n => n.NewAtomContainer(It.IsAny <IEnumerable <IAtom> >(), It.IsAny <IEnumerable <IBond> >()), Times.Once());
        }
示例#5
0
        public void TestRingFragments()
        {
            var fragment = new RingSearch(spiro).RingFragments();

            Assert.AreEqual(spiro.Atoms.Count, fragment.Atoms.Count);
            Assert.AreEqual(spiro.Bonds.Count, fragment.Bonds.Count);
        }
示例#6
0
        public void TestCyclic_Bond()
        {
            var mock_cyclicSearch            = new Mock <ICyclicVertexSearch>();
            ICyclicVertexSearch cyclicSearch = mock_cyclicSearch.Object;
            var            mock_container    = new Mock <IAtomContainer>();
            IAtomContainer container         = mock_container.Object;
            IAtom          a1        = new Mock <IAtom>().Object;
            IAtom          a2        = new Mock <IAtom>().Object;
            var            mock_bond = new Mock <IBond>();
            IBond          bond      = mock_bond.Object;

            mock_container.Setup(n => n.Atoms.IndexOf(a1)).Returns(42);
            mock_container.Setup(n => n.Atoms.IndexOf(a2)).Returns(43);
            mock_bond.Setup(n => n.Begin).Returns(a1);
            mock_bond.Setup(n => n.End).Returns(a2);

            RingSearch ringSearch = new RingSearch(container, cyclicSearch);

            ringSearch.Cyclic(bond);

            // verify the number returned from getAtomNumber is passed on
            mock_container.Verify(n => n.Atoms.IndexOf(a1), Times.Once());
            mock_container.Verify(n => n.Atoms.IndexOf(a2), Times.Once());
            mock_cyclicSearch.Verify(n => n.Cyclic(42, 43), Times.Once());
        }
示例#7
0
        public void TestRingFragments()
        {
            var fragment = new RingSearch(benzylbenzene).RingFragments();

            Assert.AreEqual(benzylbenzene.Atoms.Count - 1, fragment.Atoms.Count);
            Assert.AreEqual(benzylbenzene.Bonds.Count - 2, fragment.Bonds.Count);
        }
        public void TestIsolated()
        {
            var search   = new RingSearch(hexaphenylene);
            var isolated = search.Isolated();

            Assert.AreEqual(0, isolated.Length);
        }
        public void TestRingFragments()
        {
            var fragment = new RingSearch(biphenyl).RingFragments();

            Assert.AreEqual(biphenyl.Atoms.Count, fragment.Atoms.Count);
            Assert.AreEqual(biphenyl.Bonds.Count - 1, fragment.Bonds.Count);
        }
        public void TestFused()
        {
            var fused = new RingSearch(hexaphenylene).Fused();

            Assert.AreEqual(1, fused.Length);
            Assert.AreEqual(hexaphenylene.Atoms.Count, fused[0].Length);
        }
        public void TestRingFragments()
        {
            var fragment = new RingSearch(hexaphenylene).RingFragments();

            Assert.AreEqual(hexaphenylene.Atoms.Count, fragment.Atoms.Count);
            Assert.AreEqual(hexaphenylene.Bonds.Count, fragment.Bonds.Count);
        }
示例#12
0
        public void TestIsolatedRingFragments()
        {
            var ringSearch = new RingSearch(fusedRings);
            var fragments  = ringSearch.IsolatedRingFragments();

            Assert.AreEqual(0, fragments.Count());
        }
        public void TestIsolatedRingFragments()
        {
            var search   = new RingSearch(hexaphenylene);
            var isolated = search.IsolatedRingFragments();

            Assert.AreEqual(0, isolated.Count());
        }
示例#14
0
        public void TestRingFragments()
        {
            var n        = bicyclo.Atoms.Count;
            var fragment = new RingSearch(bicyclo).RingFragments();

            Assert.AreEqual(bicyclo.Atoms.Count, fragment.Atoms.Count);
            Assert.AreEqual(bicyclo.Bonds.Count, fragment.Bonds.Count);
        }
示例#15
0
        public void TestIsolated()
        {
            var search   = new RingSearch(benzene);
            var isolated = search.Isolated();

            Assert.AreEqual(1, isolated.Length);
            Assert.AreEqual(6, isolated[0].Length);
        }
示例#16
0
        public void TestIsolatedRingFragments()
        {
            var search   = new RingSearch(spiro);
            var isolated = search.IsolatedRingFragments().ToReadOnlyList();

            Assert.AreEqual(2, isolated.Count);
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new[] { 4, 7 }, new int[] { isolated[0].Atoms.Count, isolated[1].Atoms.Count }));
        }
示例#17
0
        public void TestIsolated()
        {
            var search   = new RingSearch(spiro);
            var isolated = search.Isolated();

            Assert.AreEqual(2, isolated.Length);
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new[] { 4, 7 }, new int[] { isolated[0].Length, isolated[1].Length }));
        }
示例#18
0
        public void TestIsolatedRingFragments()
        {
            var search   = new RingSearch(benzene);
            var isolated = search.IsolatedRingFragments().ToReadOnlyList();

            Assert.AreEqual(1, isolated.Count);
            Assert.AreEqual(6, isolated[0].Atoms.Count);
            Assert.AreEqual(6, isolated[0].Bonds.Count);
        }
示例#19
0
        public void ConnectingEdge2()
        {
            IAtomContainer mol  = TriSpiroPentane();
            RingSearch     rs   = new RingSearch(mol);
            IAtomContainer frag = rs.RingFragments();

            Assert.AreEqual(5, rs.NumRings);
            Assert.AreEqual(frag.Bonds.Count, mol.Bonds.Count);
        }
示例#20
0
        public void TestIsolated()
        {
            var search   = new RingSearch(biphenyl);
            var isolated = search.Isolated();

            Assert.AreEqual(2, isolated.Length);
            Assert.AreEqual(6, isolated[0].Length);
            Assert.AreEqual(6, isolated[1].Length);
        }
        public void TestFusedRingFragments()
        {
            var search = new RingSearch(hexaphenylene);
            var fused  = search.FusedRingFragments().ToReadOnlyList();

            Assert.AreEqual(1, fused.Count);
            Assert.AreEqual(hexaphenylene.Atoms.Count, fused[0].Atoms.Count);
            Assert.AreEqual(hexaphenylene.Bonds.Count, fused[0].Bonds.Count);
        }
示例#22
0
        public void TestCyclic_Int()
        {
            var ringSearch = new RingSearch(fusedRings);

            for (int i = 0; i < fusedRings.Atoms.Count; i++)
            {
                Assert.IsTrue(ringSearch.Cyclic(i));
            }
        }
        public void TestCyclic_Int()
        {
            int        n          = nonCyclic.Atoms.Count;
            RingSearch ringSearch = new RingSearch(nonCyclic);

            for (int i = 0; i < n; i++)
            {
                Assert.IsFalse(ringSearch.Cyclic(i));
            }
        }
        public void TestCyclic_Int()
        {
            var n          = hexaphenylene.Atoms.Count;
            var ringSearch = new RingSearch(hexaphenylene);

            for (int i = 0; i < n; i++)
            {
                Assert.IsTrue(ringSearch.Cyclic(i));
            }
        }
示例#25
0
        public void TestCyclic_Int()
        {
            var n          = spiro.Atoms.Count;
            var ringSearch = new RingSearch(spiro);

            for (int i = 0; i < n; i++)
            {
                Assert.IsTrue(ringSearch.Cyclic(i));
            }
        }
示例#26
0
        public void TestFusedRingFragments()
        {
            var fragments = new RingSearch(bicyclo).FusedRingFragments().ToReadOnlyList();

            Assert.AreEqual(1, fragments.Count);
            IAtomContainer fragment = fragments[0];

            Assert.AreEqual(bicyclo.Atoms.Count, fragment.Atoms.Count);
            Assert.AreEqual(bicyclo.Bonds.Count, fragment.Bonds.Count);
        }
示例#27
0
        public void TestCyclic_Int()
        {
            var n          = bicyclo.Atoms.Count;
            var ringSearch = new RingSearch(bicyclo);

            for (int i = 0; i < n; i++)
            {
                Assert.IsTrue(ringSearch.Cyclic(i), "all atoms should be cyclic");
            }
        }
示例#28
0
        public void TestCyclic()
        {
            var mock_cyclicSearch            = new Mock <ICyclicVertexSearch>();
            ICyclicVertexSearch cyclicSearch = mock_cyclicSearch.Object;
            IAtomContainer      container    = new Mock <IAtomContainer>().Object;

            RingSearch ringSearch = new RingSearch(container, cyclicSearch);

            ringSearch.Cyclic();

            mock_cyclicSearch.Verify(n => n.Cyclic(), Times.Once());
        }
示例#29
0
        public void TestCyclic_Atom_NotFound()
        {
            ICyclicVertexSearch cyclicSearch = new Mock <ICyclicVertexSearch>().Object;
            var            mock_container    = new Mock <IAtomContainer>();
            IAtomContainer container         = mock_container.Object;
            IAtom          atom = new Mock <IAtom>().Object;

            mock_container.Setup(n => n.Atoms.IndexOf(It.IsAny <IAtom>())).Returns(-1);

            RingSearch ringSearch = new RingSearch(container, cyclicSearch);

            ringSearch.Cyclic(atom);
        }
示例#30
0
        public void TestRingFragments()
        {
            var ringSearch = new RingSearch(fusedRings);
            var fragment   = ringSearch.RingFragments();

            foreach (var atom in fusedRings.Atoms)
            {
                Assert.IsTrue(fragment.Contains(atom));
            }
            foreach (var bond in fusedRings.Bonds)
            {
                Assert.IsTrue(fragment.Contains(bond));
            }
        }