Beispiel #1
0
        public void TestSaveMethod()
        {
            TableFile tableFile = new TableFile();

            tableFile.Load(TEST_FILE);

            MemoryStream savedStream = new MemoryStream();

            tableFile.Save(savedStream);

            savedStream.Seek(0, SeekOrigin.Begin);

            TableFile savedTableFile = new TableFile();

            savedTableFile.Load(savedStream);

            savedStream.Close();

            Assert.AreEqual(tableFile.MaximumRange, savedTableFile.MaximumRange, "Maximum range does not match");

            for (int i = 0; i < tableFile.MaximumRange; i++)
            {
                Assert.AreEqual(tableFile.StartIndices[i], tableFile.StartIndices[i], "Start index does not match");
                Assert.AreEqual(tableFile.IndexCounts[i], tableFile.IndexCounts[i], "Index count does not match");
            }

            Assert.AreEqual(tableFile.Points.Count, savedTableFile.Points.Count, "Points count does not match");

            for (int i = 0; i < tableFile.Points.Count; i++)
            {
                Assert.AreEqual(tableFile.Points[i].X, tableFile.Points[i].X, "Points do not match");
                Assert.AreEqual(tableFile.Points[i].Y, tableFile.Points[i].Y, "Points do not match");
            }
        }
Beispiel #2
0
        public void TestLoadMethod()
        {
            const int MAXIMUM_RANGE = 42;

            Stream stream = File.OpenRead(TEST_FILE);

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

            stream.Seek(0, SeekOrigin.Begin);

            TableFile tableFile = new TableFile();

            tableFile.Load(stream);

            long streamPosition = stream.Position;

            stream.Close();

            Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read");
            Assert.AreEqual(MAXIMUM_RANGE, tableFile.MaximumRange, "Incorrect maximum range");
        }