Esempio n. 1
0
        private void SaveSnapshot(string baseName, bool shouldFail = false)
        {
            Application.DoEvents();
            var filename = Path.Combine(Path.GetTempPath(), baseName);

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            var img = axMap1.SnapShot2(0, axMap1.CurrentZoom, 1000);

            Assert.IsNotNull(img, "Snapshot is null");
            var retVal = img.Save(filename);

            if (!shouldFail)
            {
                Assert.IsTrue(retVal, "Snapshot could not be saved: " + img.ErrorMsg[img.LastErrorCode]);
                Assert.IsTrue(File.Exists(filename), "The file doesn't exists.");
                DebugMsg(filename);
            }
            else
            {
                DebugMsg("Expected error: " + img.ErrorMsg[img.LastErrorCode]);
                Assert.IsFalse(retVal, "Image could be saved. This is unexpected.");
            }
        }
Esempio n. 2
0
        public static string SaveSnapshot2(AxMap axMap1, string baseName, bool shouldFail = false)
        {
            Application.DoEvents();
            var filename = Path.Combine(Path.GetTempPath(), baseName);

            DeleteFile(filename);

            var img = axMap1.SnapShot2(0, axMap1.CurrentZoom + 10, 1000);

            if (img == null)
            {
                throw new NullReferenceException("Snapshot is null");
            }

            var retVal = img.Save(filename);

            img.Close();
            if (!shouldFail)
            {
                if (!retVal)
                {
                    throw new Exception("Snapshot could not be saved: " + img.ErrorMsg[img.LastErrorCode]);
                }
                if (!File.Exists(filename))
                {
                    throw new FileNotFoundException("The file doesn't exists.", filename);
                }
                DebugMsg(filename);
            }
            else
            {
                DebugMsg("Expected error: " + img.ErrorMsg[img.LastErrorCode]);
                if (retVal)
                {
                    throw new Exception("Image could be saved. This is unexpected.");
                }
            }

            return(filename);
        }