Exemple #1
0
        public void TestNewSingleElectron_IAtom()
        {
            IChemObjectBuilder builder  = RootObject.Builder;
            ISingleElectron    electron = builder.NewSingleElectron(builder.NewAtom());

            Assert.IsNotNull(electron);
        }
        public void TestMatchAgainstItself()
        {
            var    m_bond1 = new Mock <ISingleElectron>(); ISingleElectron bond1 = m_bond1.Object;
            string result = SingleElectronDiff.Diff(bond1, bond1);

            AssertZeroLength(result);
        }
Exemple #3
0
        public override void TestClone()
        {
            ISingleElectron radical = (ISingleElectron)NewChemObject();
            object          clone   = radical.Clone();

            Assert.IsNotNull(clone);
            Assert.IsTrue(clone is ISingleElectron);
        }
Exemple #4
0
        public virtual void TestGetAtom()
        {
            IChemObject     obj     = NewChemObject();
            IAtom           atom    = obj.Builder.NewAtom("N");
            ISingleElectron radical = obj.Builder.NewSingleElectron(atom);

            Assert.AreEqual(atom, radical.Atom);
        }
Exemple #5
0
        public virtual void TestContains_IAtom()
        {
            IChemObject     obj     = NewChemObject();
            IAtom           atom    = obj.Builder.NewAtom("N");
            ISingleElectron radical = obj.Builder.NewSingleElectron(atom);

            Assert.IsTrue(radical.Contains(atom));
        }
Exemple #6
0
        public virtual void TestSetAtom_IAtom()
        {
            ISingleElectron radical = (ISingleElectron)NewChemObject();
            IAtom           atom    = radical.Builder.NewAtom("N");

            Assert.IsNull(radical.Atom);
            radical.Atom = atom;
            Assert.AreEqual(atom, radical.Atom);
        }
Exemple #7
0
        public override void TestToString()
        {
            ISingleElectron radical     = (ISingleElectron)NewChemObject();
            string          description = radical.ToString();

            for (int i = 0; i < description.Length; i++)
            {
                Assert.IsTrue(description[i] != '\n');
                Assert.IsTrue(description[i] != '\r');
            }
        }
Exemple #8
0
        public virtual void TestClone_IAtom()
        {
            ISingleElectron radical = (ISingleElectron)NewChemObject();
            IAtom           atom    = radical.Builder.NewAtom("N");

            radical.Atom = atom;

            // test cloning of atom
            ISingleElectron clone = (ISingleElectron)radical.Clone();

            Assert.AreNotSame(atom, clone.Atom);
        }
        /// <summary>
        /// Compare two <see cref="IChemObject"/> classes and return the difference as an <see cref="IDifference"/>.
        /// </summary>
        /// <param name="first">the first of the two classes to compare</param>
        /// <param name="second">the second of the two classes to compare</param>
        /// <returns>an <see cref="IDifference"/> representation of the difference between the first and second <see cref="IChemObject"/>.</returns>
        public static IDifference Difference(IChemObject first, IChemObject second)
        {
            if (!(first is ISingleElectron && second is ISingleElectron))
            {
                return(null);
            }
            ISingleElectron firstB    = (ISingleElectron)first;
            ISingleElectron secondB   = (ISingleElectron)second;
            IDifferenceList totalDiff = new ChemObjectDifference("SingleElectronDiff");

            totalDiff.AddChild(AtomDiff.Difference(firstB.Atom, secondB.Atom));
            totalDiff.AddChild(ElectronContainerDiff.Difference(first, second));
            if (totalDiff.ChildCount() > 0)
            {
                return(totalDiff);
            }
            else
            {
                return(null);
            }
        }
        public void TestDiff()
        {
            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_bond1 = new Mock <ISingleElectron>(); ISingleElectron bond1 = m_bond1.Object;
            var m_bond2 = new Mock <ISingleElectron>(); ISingleElectron bond2 = m_bond2.Object;

            m_bond1.SetupGet(n => n.Atom).Returns(carbon);
            m_bond2.SetupGet(n => n.Atom).Returns(oxygen);

            string result = SingleElectronDiff.Diff(bond1, bond2);

            Assert.IsNotNull(result);
            Assert.AreNotSame(0, result.Length);
            AssertContains(result, "SingleElectronDiff");
            AssertContains(result, "AtomDiff");
            AssertContains(result, "C/O");
        }
Exemple #11
0
 public bool Contains(ISingleElectron singleElectron)
 => false;
Exemple #12
0
        public override void TestGetElectronCount()
        {
            ISingleElectron radical = (ISingleElectron)NewChemObject();

            Assert.AreEqual(1, radical.ElectronCount.Value);
        }