public void TestGetMaximalFormula_MolecularFormulaRange_IChemObjectBuilder()
        {
            var mf1 = new MolecularFormula(); /* C4H12NO4 */

            mf1.Add(builder.NewIsotope("C"), 4);
            mf1.Add(builder.NewIsotope("H"), 12);
            mf1.Add(builder.NewIsotope("N"), 1);
            mf1.Add(builder.NewIsotope("O"), 4);

            var mf2 = new MolecularFormula(); /* C7H20N4O2 */

            mf2.Add(builder.NewIsotope("C"), 7);
            mf2.Add(builder.NewIsotope("H"), 20);
            mf2.Add(builder.NewIsotope("N"), 4);
            mf2.Add(builder.NewIsotope("O"), 2);

            var mf3 = new MolecularFormula(); /* C9H5O7 */

            mf3.Add(builder.NewIsotope("C"), 9);
            mf3.Add(builder.NewIsotope("H"), 5);
            mf3.Add(builder.NewIsotope("O"), 7);

            var mfSet = new MolecularFormulaSet
            {
                mf1,
                mf2,
                mf3
            };

            MolecularFormulaRange mfRange = MolecularFormulaRangeManipulator.GetRange(mfSet);
            IMolecularFormula     formula = MolecularFormulaRangeManipulator.GetMaximalFormula(mfRange, builder);

            /* Result: C4-9H5-20N0-4O2-7 */

            Assert.AreEqual(4, mfRange.GetIsotopes().Count());
            Assert.AreEqual(formula.GetCount(builder.NewIsotope("C")),
                            mfRange.GetIsotopeCountMax(builder.NewIsotope("C")));
            Assert.AreEqual(formula.GetCount(builder.NewIsotope("H")),
                            mfRange.GetIsotopeCountMax(builder.NewIsotope("H")));
            Assert.AreEqual(formula.GetCount(builder.NewIsotope("N")),
                            mfRange.GetIsotopeCountMax(builder.NewIsotope("N")));
            Assert.AreEqual(formula.GetCount(builder.NewIsotope("O")),
                            mfRange.GetIsotopeCountMax(builder.NewIsotope("O")));
        }
        public void TestGetRange_IMolecularFormulaSet()
        {
            var mf1 = new MolecularFormula(); /* C4H12NO4 */

            mf1.Add(builder.NewIsotope("C"), 4);
            mf1.Add(builder.NewIsotope("H"), 12);
            mf1.Add(builder.NewIsotope("N"), 1);
            mf1.Add(builder.NewIsotope("O"), 4);

            var mf2 = new MolecularFormula(); /* C7H20N4O2 */

            mf2.Add(builder.NewIsotope("C"), 7);
            mf2.Add(builder.NewIsotope("H"), 20);
            mf2.Add(builder.NewIsotope("N"), 4);
            mf2.Add(builder.NewIsotope("O"), 2);

            var mf3 = new MolecularFormula(); /* C9H5O7 */

            mf3.Add(builder.NewIsotope("C"), 9);
            mf3.Add(builder.NewIsotope("H"), 5);
            mf3.Add(builder.NewIsotope("O"), 7);

            var mfSet = new MolecularFormulaSet
            {
                mf1,
                mf2,
                mf3
            };

            MolecularFormulaRange mfRange = MolecularFormulaRangeManipulator.GetRange(mfSet);

            /* Result: C4-9H5-20N0-4O2-7 */

            Assert.AreEqual(4, mfRange.GetIsotopes().Count());
            Assert.AreEqual(4, mfRange.GetIsotopeCountMin(builder.NewIsotope("C")));
            Assert.AreEqual(9, mfRange.GetIsotopeCountMax(builder.NewIsotope("C")));
            Assert.AreEqual(5, mfRange.GetIsotopeCountMin(builder.NewIsotope("H")));
            Assert.AreEqual(20, mfRange.GetIsotopeCountMax(builder.NewIsotope("H")));
            Assert.AreEqual(0, mfRange.GetIsotopeCountMin(builder.NewIsotope("N")));
            Assert.AreEqual(4, mfRange.GetIsotopeCountMax(builder.NewIsotope("N")));
            Assert.AreEqual(2, mfRange.GetIsotopeCountMin(builder.NewIsotope("O")));
            Assert.AreEqual(7, mfRange.GetIsotopeCountMax(builder.NewIsotope("O")));
        }