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"); }
public void TestRemoveObjectFromChemicalFormula() { ChemicalFormula formulaB = new ChemicalFormula("CO"); var ok = new PhysicalObjectWithChemicalFormula("C"); formulaB.Remove(ok); Assert.AreEqual("O", formulaB.Formula); }
public void AddIChemicalFormulaToFormula() { ChemicalFormula formulaA = new ChemicalFormula("C2H3NO"); IHasChemicalFormula formulaB = new PhysicalObjectWithChemicalFormula("H2O"); ChemicalFormula formulaC = new ChemicalFormula("C2H5NO2"); formulaA.Add(formulaB); Assert.AreEqual(formulaA, formulaC); }
public void TestIsotopicDistribution3() { ChemicalFormula formulaA = new ChemicalFormula("CO"); // Distinguish between O and C isotope masses var a = new IsotopicDistribution(formulaA, 0.0001); Assert.AreEqual(6, a.Masses.Count()); // Do not distinguish between O and C isotope masses new IsotopicDistribution(formulaA, 0.001); // Do not distinguish between O and C isotope masses var b = new IsotopicDistribution(formulaA); Assert.AreEqual(4, b.Masses.Count()); new IsotopicDistribution(formulaA, 0.1); PhysicalObjectWithChemicalFormula formulaB = new PhysicalObjectWithChemicalFormula("CO"); new IsotopicDistribution(formulaB.ThisChemicalFormula, 1); }