コード例 #1
0
        /// <summary>
        /// Validate the DEM files name for different test cases.
        /// </summary>
        /// <param name="expectedFileName">Expected file name.</param>
        /// <param name="level">Levels in the folder structure.</param>
        /// <param name="tileXValue">Tile X value.</param>
        /// <param name="tileYValue">Tile Y value.</param>
        public void ValidateDeserializeDEMDifferentLevel(string expectedFileName, int level, int tileXValue, int tileYValue)
        {
            string destinationPath = Path.Combine(Environment.CurrentDirectory, fileTemplate);
            var demTileSerializer = new DemTileSerializer(destinationPath);

            short[] values = new short[1089];
            Random random = new Random();
            for (int index = 0; index < 1089; index++)
            {
                values[index] = Convert.ToInt16(random.Next(100));
            }

            demTileSerializer.Serialize(values, level, tileXValue, tileYValue);

            // Validate the file structure created and the files
            string actualPath = demTileSerializer.GetFileName(level, tileXValue, tileYValue);
            Assert.AreEqual(actualPath, Path.Combine(Environment.CurrentDirectory, expectedFileName));
            Assert.IsTrue(File.Exists(actualPath));

            var newBytes = demTileSerializer.Deserialize(level, tileXValue, tileYValue);

            // Assert that the deserialized bitmap is not null and holds original values.
            Assert.IsNotNull(newBytes);
            for (int i = 0; i < values.Length; i++)
            {
                Assert.AreEqual(values[i], newBytes[i]);
            }

            // Delete the file.
            File.Delete(actualPath);
        }
コード例 #2
0
        /// <summary>
        /// Validate the DEM files name for different test cases.
        /// </summary>
        /// <param name="expectedFileName">Expected file name.</param>
        /// <param name="level">Levels in the folder structure.</param>
        /// <param name="tileXValue">Tile X value.</param>
        /// <param name="tileYValue">Tile Y value.</param>
        public void ValidateDEMFilesForDifferentLevel(string expectedFileName, int level, int tileXValue, int tileYValue)
        {
            string destinationPath = Path.Combine(Environment.CurrentDirectory, fileTemplate);
            var demTileSerializer = new DemTileSerializer(destinationPath);

            // Validate destination path
            Assert.AreEqual(demTileSerializer.DestinationPath, destinationPath);

            short[] values = new short[1089];
            Random random = new Random();
            for (int index = 0; index < 1089; index++)
            {
                values[index] = Convert.ToInt16(random.Next(100));
            }

            demTileSerializer.Serialize(values, level, tileXValue, tileYValue);

            // Validate the file structure created and the files
            string actualPath = demTileSerializer.GetFileName(level, tileXValue, tileYValue);
            Assert.AreEqual(actualPath, Path.Combine(Environment.CurrentDirectory, expectedFileName));
            Assert.IsTrue(File.Exists(actualPath));

            // Delete the file.
            File.Delete(actualPath);
        }