コード例 #1
0
        public void CSVFileToArray_FileIsEmpty_ReturnsEmptyArray()
        {
            string csvFilename = fileNameEmpty;

            double[,] data;
            data = CSVFileParser.ToArray(csvFilename);
        }
コード例 #2
0
        public void CSVFileToArray_FileHasHeaderOnly_ReturnsEmptyArray()
        {
            string csvFilename = "fileWithOnlyHeader.csv";

            double[,] data;
            data = CSVFileParser.ToArray(csvFilename, 1);
            Assert.IsNotNull(data, "array is null");
            Assert.AreEqual(0, data.GetLength(0), "array dim0 should be 0");
            Assert.AreEqual(0, data.GetLength(1), "array dim1 should be 0");
        }
コード例 #3
0
        public void CSVFileToArray_FileHasContentAndHeader_ArrayIsRightSize()
        {
            string csvFilename = "FileWithHeader.csv";

            double[,] data;
            data = CSVFileParser.ToArray(csvFilename, 1);
            Assert.IsNotNull(data);
            Assert.AreEqual(3, data.GetLength(0), "array dim0 should be 3");
            Assert.AreEqual(3, data.GetLength(1), "array dim1 should be 3");
            Assert.AreEqual(9, data.Length, "length");
        }
コード例 #4
0
ファイル: XSection.cs プロジェクト: 1907931256/MasterProject
        public XSection(string XsectionCsvFile, int firstDataRow, int firstDataColumn)
        {
            double[,] pointArr = CSVFileParser.ToArray(XsectionCsvFile, firstDataRow);

            for (int i = firstDataRow; i < pointArr.GetLength(0); i++)
            {
                double x = pointArr[i, firstDataColumn];
                double y = Math.Abs(pointArr[i, firstDataColumn + 1]);
                Add(new Vector2(x, y));
            }
            SortByX();
            Origin   = this[0];
            MeshSize = this[1].X - this[0].X;
            Width    = this[Count - 1].X - Origin.X;
        }
コード例 #5
0
        public void CSVFileToArray_FileHasContentAndHeader_ReturnsAllContent()
        {
            string csvFilename = "FileWithHeader.csv";

            double[,] data;
            data = CSVFileParser.ToArray(csvFilename, 1);
            Assert.IsNotNull(data);
            Assert.AreEqual(3, data.GetLength(0), "array dim0 should be 3");
            Assert.AreEqual(3, data.GetLength(1), "array dim1 should be 3");
            Assert.AreEqual(9, data.Length, "length");

            Assert.AreEqual(1.0, (double)data[0, 0], "r0,c0");
            Assert.AreEqual(4.0, (double)data[1, 0], " r1,c0");
            Assert.AreEqual(5.0, (double)data[1, 1], " r1,c1");
            Assert.AreEqual(7.0, (double)data[2, 0], " r2,c0");
            Assert.AreEqual(9.0, (double)data[2, 2], " r2,c2");
        }