Exemplo n.º 1
0
        public void AppendFromRawDataTest()
        {
            Assert.Throws <InvalidDataException>(code: () => { _dataset.AppendFromRawData(data: null, coordinates: null); },
                                                 message: "Dataset accepted null raw data.");

            Assert.AreEqual(_dataset.SpectrumCount,
                            actual: 3,
                            message: "Dataset has been changed while appending null data.");

            double[,] newData = { { 0.1 } };

            Assert.Throws <InvalidDataException>(code: () => { _dataset.AppendFromRawData(newData, coordinates: null); },
                                                 message: "Dataset accepted raw data of different lengths.");

            Assert.AreEqual(_dataset.SpectrumCount, actual: 3);

            newData = new[, ] {
                { 2, 2.1, 2.2 }, { 3, 3.1, 3.2 }, { 4, 4.1, 4.2 }
            };
            int[,] coords = { { 1, 2, 3 } };

            Assert.Throws <InvalidDataException>(code: () => { _dataset.AppendFromRawData(newData, coords); },
                                                 message: "Dataset accepted spatial coordinates array of length different than data.");

            coords = new[, ] {
                { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }
            };

            Assert.DoesNotThrow(code: () => { _dataset.AppendFromRawData(newData, coords); },
                                message: "Dataset failed to append correct raw data.");

            Assert.AreEqual(_dataset.SpectrumCount,
                            actual: 6,
                            message: "Dataset failed to load spectras correctly.");
            Assert.AreEqual(expected: _dataset.SpatialCoordinates.Count(),
                            actual: 6,
                            message: "Dataset do not assign spacial coordinates per spectrum.");
            Assert.AreEqual(expected: _dataset.GetRawIntensityValue(spectrumIdx: 4, valueIdx: 1),
                            actual: 3.1,
                            message: "Dataset appended incorrect values.");
        }