public void TestDefaultValidFalse() { IRule rule = new ElementRule(); var formula = new MolecularFormula(); formula.Add(builder.NewIsotope("C"), 2); formula.Add(builder.NewIsotope("H"), 200); Assert.AreEqual(0.0, rule.Validate(formula), 0.0001); }
public void TestDefaultValidFalseSetParam() { IRule rule = new ElementRule(); var formula = new MolecularFormula(); formula.Add(builder.NewIsotope("C"), 2); formula.Add(builder.NewIsotope("H"), 6); MolecularFormulaRange mfRange = new MolecularFormulaRange(); mfRange.AddIsotope(builder.NewIsotope("C"), 1, 2); mfRange.AddIsotope(builder.NewIsotope("H"), 1, 2); rule.Parameters = new object[] { mfRange }; Assert.AreEqual(0.0, rule.Validate(formula), 0.0001); }
public void TestSetParameters() { IRule rule = new ElementRule(); MolecularFormulaRange mfRange = new MolecularFormulaRange(); mfRange.AddIsotope(builder.NewIsotope("C"), 1, 10); mfRange.AddIsotope(builder.NewIsotope("H"), 1, 10); rule.Parameters = new object[] { mfRange }; var objects = rule.Parameters; Assert.AreEqual(1, objects.Count); MolecularFormulaRange mfRange2 = (MolecularFormulaRange)objects[0]; Assert.AreEqual(mfRange.Count, mfRange2.Count); Assert.AreEqual(mfRange.GetIsotopeCountMin(new Isotope("C")), mfRange2.GetIsotopeCountMin(new Isotope("C"))); Assert.AreEqual(mfRange.GetIsotopeCountMax(new Isotope("C")), mfRange2.GetIsotopeCountMax(new Isotope("C"))); }
public void TestDefault() { IRule rule = new ElementRule(); var objects = rule.Parameters; // MolecularFormulaRange needs a build to create isotopes Assert.AreEqual(1, objects.Count); Assert.IsNull(objects[0]); // when we do a validation... rule.Validate(new MolecularFormula()); // a default option is created objects = rule.Parameters; Assert.AreEqual(1, objects.Count); Assert.IsNotNull(objects[0]); MolecularFormulaRange mfRange = (MolecularFormulaRange)objects[0]; Assert.AreEqual(93, mfRange.Count); Assert.AreEqual(0, mfRange.GetIsotopeCountMin(new Isotope("C"))); Assert.AreEqual(50, mfRange.GetIsotopeCountMax(new Isotope("C"))); }
public void TestElementRule() { IRule rule = new ElementRule(); Assert.IsNotNull(rule); }