示例#1
0
        public void TestDifference()
        {
            var m_carbon = new Mock <IAtom>(); IAtom carbon = m_carbon.Object;
            var m_oxygen = new Mock <IAtom>(); IAtom oxygen = m_oxygen.Object;

            m_carbon.SetupGet(n => n.Symbol).Returns("C");
            m_oxygen.SetupGet(n => n.Symbol).Returns("O");

            var m_b1 = new Mock <IBond>(); IBond b1 = m_b1.Object;
            var m_b2 = new Mock <IBond>(); IBond b2 = m_b2.Object;

            m_b1.SetupGet(n => n.Order).Returns(BondOrder.Single);
            m_b2.SetupGet(n => n.Order).Returns(BondOrder.Double);

            m_b1.SetupGet(n => n.Atoms.Count).Returns(2);
            m_b2.SetupGet(n => n.Atoms.Count).Returns(2);

            m_b1.SetupGet(n => n.Begin).Returns(carbon);
            m_b1.SetupGet(n => n.End).Returns(carbon);
            m_b2.SetupGet(n => n.Begin).Returns(carbon);
            m_b2.SetupGet(n => n.End).Returns(oxygen);

            var m_container1 = new Mock <IAtomContainer>(); IAtomContainer container1 = m_container1.Object;
            var m_container2 = new Mock <IAtomContainer>(); IAtomContainer container2 = m_container2.Object;

            m_container1.Setup(n => n.GetElectronContainers().Count()).Returns(1);
            m_container2.Setup(n => n.GetElectronContainers().Count()).Returns(1);
            m_container1.Setup(n => n.GetElectronContainers().First()).Returns(b1);
            m_container2.Setup(n => n.GetElectronContainers().First()).Returns(b2);

            string result = AtomContainerDiff.Diff(container1, container2);

            Assert.IsNotNull(result);
        }
示例#2
0
        public void TestMatchAgainstItself()
        {
            var m_container = new Mock <IAtomContainer>(); IAtomContainer container = m_container.Object;

            m_container.Setup(n => n.GetElectronContainers().Count()).Returns(1);
            m_container.Setup(n => n.GetElectronContainers().First()).Returns(new Mock <IBond>().Object);
            string result = AtomContainerDiff.Diff(container, container);

            AssertZeroLength(result);
        }