Example #1
0
        public void BalanceTest7()
        {
            String        s1       = "CuN2O6 + NO + H2O = Cu + HNO3";
            String        expected = "3CuN2O6 + 2NO + 4H2O = 3Cu + 8HNO3";
            ChemEqnMatrix cm       = new ChemEqnMatrix(s1);
            string        result   = cm.Balance();

            Assert.AreEqual(expected, result);
        }
Example #2
0
        public void BalanceTest5()
        {
            String        s1       = "C6HOF2Ne = C3HOFNe + C";
            String        expected = "No solution";
            ChemEqnMatrix cm       = new ChemEqnMatrix(s1);
            string        result   = cm.Balance();

            Assert.AreEqual(expected, result);
        }
Example #3
0
        public void BalanceTest6()
        {
            String        s1       = "CHCl3 + O2 = CO2 + H2O + Cl2";
            String        expected = "4CHCl3 + 5O2 = 4CO2 + 2H2O + 6Cl2";
            ChemEqnMatrix cm       = new ChemEqnMatrix(s1);
            string        result   = cm.Balance();

            Assert.AreEqual(expected, result);
        }
Example #4
0
        public void BalanceTest3()
        {
            String        s1       = "H2O6 = O2 + H2";
            String        expected = "H2O6 = 3O2 + H2";
            ChemEqnMatrix cm       = new ChemEqnMatrix(s1);
            string        result   = cm.Balance();

            Assert.AreEqual(expected, result);
        }
Example #5
0
        public void BalanceTest4()
        {
            String        s1       = "CHOFNe = CHOFNe";
            String        expected = "CHOFNe = CHOFNe";
            ChemEqnMatrix cm       = new ChemEqnMatrix(s1);
            string        result   = cm.Balance();

            Assert.AreEqual(expected, result);
        }
Example #6
0
        public void BalanceTest2()
        {
            String        s1       = "C6H12O6 + O2 = CO2 + H2O";
            String        expected = "C6H12O6 + 6O2 = 6CO2 + 6H2O";
            ChemEqnMatrix cm       = new ChemEqnMatrix(s1);
            string        result   = cm.Balance();

            Assert.AreEqual(expected, result);
        }
Example #7
0
        public void GetLCMDiagonalTest1()
        {
            String        s  = "CHCl3 + O2 = CO2 + H2O + Cl2";
            ChemEqnMatrix cm = new ChemEqnMatrix(s);

            cm.Balance();
            double expected = 4;
            double result   = cm.GetLCMDiagonal();

            Assert.AreEqual(expected, result);
        }
Example #8
0
        public void GetLCMDiagonalTest()
        {
            String        s  = "CO2 + H2O = C6H12O6 + O2";
            ChemEqnMatrix cm = new ChemEqnMatrix(s);

            cm.Balance();
            double expected = 6;
            double result   = cm.GetLCMDiagonal();

            Assert.AreEqual(expected, result);
        }
Example #9
0
        public void DetermineCoefficientsTest2()
        {
            String        s  = "C6HOF2Ne = C3HOFNe + C";
            ChemEqnMatrix cm = new ChemEqnMatrix(s);

            cm.Balance();
            int[] expected = { 1, 1, 0 };
            int[] result   = cm.DetermineCoefficients();
            for (int i = 0; i < result.Length; i++)
            {
                Assert.AreEqual(expected[i], result[i]);
            }
        }
Example #10
0
        public void DetermineCoefficientsTest1()
        {
            String        s  = "CHCl3 + O2 = CO2 + H2O + Cl2";
            ChemEqnMatrix cm = new ChemEqnMatrix(s);

            cm.Balance();
            int[] expected = { 4, 5, 4, 2, 6 };
            int[] result   = cm.DetermineCoefficients();
            for (int i = 0; i < result.Length; i++)
            {
                Assert.AreEqual(expected[i], result[i]);
            }
        }
Example #11
0
        public void DetermineCoefficientsTest()
        {
            String        s  = "CO2 + H2O = C6H12O6 + O2";
            ChemEqnMatrix cm = new ChemEqnMatrix(s);

            cm.Balance();
            int[] expected = { 6, 6, 1, 6 };
            int[] result   = cm.DetermineCoefficients();
            for (int i = 0; i < result.Length; i++)
            {
                Assert.AreEqual(expected[i], result[i]);
            }
        }
Example #12
0
        public void GetDiagonalTest1()
        {
            String        s  = "CO2 + H2O = C6H12O6 + O2";
            ChemEqnMatrix cm = new ChemEqnMatrix(s);

            cm.Balance();
            double[] expected = { 1, 1, 6, 1 };
            double[] result   = cm.GetDiagonal();
            for (int i = 0; i < result.Length; i++)
            {
                Assert.AreEqual(expected[i], result[i]);
            }
        }