Ejemplo n.º 1
0
        public void TestCalculate_NoModifications()
        {
            var atom  = Water.Atoms[1];
            var clone = (IAtom)Water.Atoms[1].Clone();

            Descriptor.Calculate(atom);
            var diff = AtomDiff.Diff(clone, atom);

            Assert.AreEqual(0, diff.Length, $"The descriptor must not change the passed atom in any respect, but found this diff: {diff}");
        }
Ejemplo n.º 2
0
        public void TestCalculate_IronOxide()
        {
            var material = CDK.Builder.NewSubstance();

            material.Add(MolecularFormulaManipulator.GetAtomContainer("Fe3O4", material.Builder));
            var value = Descriptor.Calculate(material);

            Assert.IsNotNull(value);
            Assert.AreEqual(4, value.Value);
        }
Ejemplo n.º 3
0
        public void TestCalculate_IAtomContainer()
        {
            var v = Descriptor.Calculate(Water.Atoms[1]);

            Assert.IsNotNull(v);
            Trace.Assert(v != null);
            if (v.Exception == null)
            {
                Assert.AreNotEqual(0, v.Count, $"{typeof(T).FullName}: The descriptor did not calculate any value.");
            }
        }
Ejemplo n.º 4
0
        public void TestLabels()
        {
            var typeName = typeof(T).FullName;
            var v        = Descriptor.Calculate(Water.Atoms[1]);

            Assert.IsNotNull(v);
            if (v.Exception == null)
            {
                var names = v.Keys;
                Assert.IsNotNull(names, $"{typeName}: The descriptor must return labels using the Names method.");
                Assert.AreNotEqual(0, names.Count(), $"{typeName}: At least one label must be given.");
                foreach (var name in names)
                {
                    Assert.IsNotNull(name, $"{typeName}: A descriptor label may not be null.");
                    Assert.AreNotEqual(0, name.Length, $"{typeName}: The label string must not be empty.");
                }
                Assert.IsNotNull(v.Values, $"{typeName}");
                Assert.AreEqual(names.Count(), v.Values.Count(), $"{typeName}: The number of labels must equals the number of values.");
            }
        }