public void XyFileWithOwnX() { //Arrange var spectra = new SpectrumCollection() { Spectra = new[] { new Spectrum( x: new[] { 1, 2, 3.0, 4, 5, 6, 7, 8.5, 9, 10 }, y: new[] { 1, 2, 3, 2, 4.0, 6.1, 7, 8, 9, Math.PI }), new Spectrum( x: new[] { 4, 5, 6, 7, 8.0, 9, 10, 11, 12, 13 }, y: new[] { 1, 1, 1, 2, 0, 2, 0, 2.0, 3.0, 1 }), } }; //Act var bytes = SpcWriter.Encode(spectra); var spc2 = SpcReader.Read(bytes); var decoded = spc2; //Assert Assert.AreEqual(2, decoded.Spectra[0].Y[1]); }
public void XyFileWithSharedUnevenX() { //Arrange var xAxes = new[] { 1, 2, 3.0, 4, 5, 6, 7, 8.5, 9, 10 }; var spectra = new SpectrumCollection() { Memo = "Polystyrene", XUnit = XZUnit.RamanShift, YUnit = YUnit.Counts, Spectra = new[] { new Spectrum( x: xAxes, y: new[] { 1, 2, 3, 2, 4.0, 6.1, 7, 8, 9, Math.PI }), new Spectrum( x: xAxes, y: new[] { 1, 1, 1, 2, 0, 2, 0, 2.0, 3.0, 1 }), }, MetaData = new Dictionary <string, string>() { { "Foo", "Bar" }, { "Bar", "Buz" } } }; //Act var bytes = SpcWriter.Encode(spectra); var spc2 = SpcReader.Read(bytes); var decoded = spc2; //Assert Assert.AreEqual("Polystyrene", decoded.Memo); Assert.AreEqual(XZUnit.RamanShift, decoded.XUnit); Assert.AreEqual(YUnit.Counts, decoded.YUnit); Assert.AreEqual(2, decoded.Spectra[0].Y[1]); Assert.IsTrue(decoded.MetaData.ContainsKey("Foo")); }