public void TestAccepts() { ShelXReader reader = new ShelXReader(new StringReader("")); Assert.IsTrue(reader.Accepts(typeof(ChemFile))); Assert.IsTrue(reader.Accepts(typeof(Crystal))); }
public void TestReading() { var filename = "NCDK.Data.ShelX.frame_1.res"; Trace.TraceInformation("Testing: " + filename); var ins = ResourceLoader.GetAsStream(filename); ShelXReader reader = new ShelXReader(ins); Crystal crystal = (Crystal)reader.Read(new Crystal()); reader.Close(); Assert.IsNotNull(crystal); Assert.AreEqual(42, crystal.Atoms.Count); var notional = CrystalGeometryTools.CartesianToNotional(crystal.A, crystal.B, crystal.C); Assert.AreEqual(7.97103, notional[0], 0.001); Assert.AreEqual(18.77220, notional[1], 0.001); Assert.AreEqual(10.26222, notional[2], 0.001); Assert.AreEqual(90.0000, notional[3], 0.001); Assert.AreEqual(90.0000, notional[4], 0.001); Assert.AreEqual(90.0000, notional[5], 0.001); }
public void TestRoundTrip() { Crystal crystal = new Crystal(); double a = 3.0; double b = 5.0; double c = 7.0; double alpha = 90.0; double beta = 110.0; double gamma = 100.0; var axes = CrystalGeometryTools.NotionalToCartesian(a, b, c, alpha, beta, gamma); crystal.A = axes[0]; crystal.B = axes[1]; crystal.C = axes[2]; // serialazing StringWriter sWriter = new StringWriter(); ShelXWriter resWriter = new ShelXWriter(sWriter); resWriter.Write(crystal); resWriter.Close(); string resContent = sWriter.ToString(); // deserialazing ShelXReader resReader = new ShelXReader(new StringReader(resContent)); ICrystal rCrystal = (ICrystal)resReader.Read(new Crystal()); // OK, do checking Assert.IsNotNull(rCrystal); Assert.AreEqual(crystal.A.X, rCrystal.A.X, 0.001); Assert.AreEqual(crystal.A.Y, rCrystal.A.Y, 0.001); Assert.AreEqual(crystal.A.Z, rCrystal.A.Z, 0.001); Assert.AreEqual(crystal.B.X, rCrystal.B.X, 0.001); Assert.AreEqual(crystal.B.Y, rCrystal.B.Y, 0.001); Assert.AreEqual(crystal.B.Z, rCrystal.B.Z, 0.001); Assert.AreEqual(crystal.C.X, rCrystal.C.X, 0.001); Assert.AreEqual(crystal.C.Y, rCrystal.C.Y, 0.001); Assert.AreEqual(crystal.C.Z, rCrystal.C.Z, 0.001); }