示例#1
0
        public void TestLoadMethod()
        {
            const int ROW_COUNT = 5501;
            const int COLUMN_COUNT = 6;

            Stream stream = File.OpenRead(TEST_FILE);

            stream.Seek(0, SeekOrigin.End);
            long fileSize = stream.Position;
            stream.Seek(0, SeekOrigin.Begin);

            DataFile dataFile = new DataFile();
            dataFile.Load(stream);

            long streamPosition = stream.Position;
            stream.Close();

            Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read");
            Assert.AreEqual(ROW_COUNT, dataFile.RowCount, "Incorrect row count");
            Assert.AreEqual(COLUMN_COUNT, dataFile.ColumnCount, "Incorrect column count");
        }
示例#2
0
        public void TestSaveMethod()
        {
            DataFile dataFile = new DataFile();
            dataFile.Load(TEST_FILE);

            MemoryStream savedStream = new MemoryStream();
            dataFile.Save(savedStream);
            savedStream.Seek(0, SeekOrigin.Begin);

            DataFile savedDataFile = new DataFile();
            savedDataFile.Load(savedStream);
            savedStream.Close();

            Assert.AreEqual(dataFile.RowCount, savedDataFile.RowCount, "Row counts do not match");
            Assert.AreEqual(dataFile.ColumnCount, savedDataFile.ColumnCount, "Column counts do not match");

            for (int i = 0; i < dataFile.RowCount; i++) {
                for (int j = 0; j < dataFile.ColumnCount; j++) {
                    Assert.AreEqual(dataFile[i][j], savedDataFile[i][j], "Cell values do not match");
                }
            }
        }