Example #1
0
        public void TestNullArguments()
        {
            ChemicalFormula     formulaA = new ChemicalFormula("CO");
            IHasChemicalFormula ok       = null;

            Assert.AreEqual("item", Assert.Throws <ArgumentNullException>(() => { formulaA.Add(ok); }).ParamName);
            ChemicalFormula ok2 = null;

            Assert.AreEqual("formula", Assert.Throws <ArgumentNullException>(() => { formulaA.Add(ok2); }).ParamName);
            Assert.AreEqual("other", Assert.Throws <ArgumentNullException>(() => { new ChemicalFormula(ok2); }).ParamName);
            Element ok3 = null;

            Assert.AreEqual("element", Assert.Throws <ArgumentNullException>(() => { formulaA.AddPrincipalIsotopesOf(ok3, 0); }).ParamName);
            Assert.AreEqual("item", Assert.Throws <ArgumentNullException>(() => { formulaA.Remove(ok); }).ParamName);
            Assert.AreEqual("formula", Assert.Throws <ArgumentNullException>(() => { formulaA.Remove(ok2); }).ParamName);
            Assert.AreEqual("formula", Assert.Throws <ArgumentNullException>(() => { formulaA.IsSubsetOf(ok2); }).ParamName);
            Assert.AreEqual("formula", Assert.Throws <ArgumentNullException>(() => { formulaA.IsSupersetOf(ok2); }).ParamName);
            Assert.AreEqual("element", Assert.Throws <ArgumentNullException>(() => { formulaA.CountWithIsotopes(ok3); }).ParamName);
            Assert.AreEqual("element", Assert.Throws <ArgumentNullException>(() => { formulaA.CountSpecificIsotopes(ok3, 0); }).ParamName);
            Assert.IsFalse(formulaA.Equals(ok2));
            IEnumerable <IHasChemicalFormula> ok4 = null;

            Assert.AreEqual("formulas", Assert.Throws <ArgumentNullException>(() => { ChemicalFormula.Combine(ok4); }).ParamName);
            Assert.AreEqual("element", Assert.Throws <ArgumentNullException>(() => { PeriodicTable.Add(ok3); }).ParamName);

            Assert.AreEqual("formula", Assert.Throws <ArgumentNullException>(() => { new IsotopicDistribution(ok2); }).ParamName);

            IHasMass ok5 = null;

            Assert.AreEqual("objectWithMass", Assert.Throws <ArgumentNullException>(() => { ok5.ToMZ(0); }).ParamName);

            var ok7 = new PhysicalObjectWithChemicalFormula("C");
        }