Ejemplo n.º 1
0
        public void Constructor3_Message_Null()
        {
            ArithmeticException   ame = new ArithmeticException("something");
            FileNotFoundException fnf = new FileNotFoundException((string)null, ame);

#if NET_2_0
            Assert.IsNotNull(fnf.Data, "#1");
#endif
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNotNull(fnf.InnerException, "#3");
            Assert.AreSame(ame, fnf.InnerException, "#4");
#if NET_2_0
            Assert.IsNull(fnf.Message, "#5");
#else
            Assert.IsNotNull(fnf.Message, "#5");              // File or assembly name (null), or ...
#endif
            Assert.IsNull(fnf.FusionLog, "#6");
#if NET_2_0
            Assert.AreEqual(fnf.GetType().FullName + ":  ---> "
                            + ame.GetType().FullName + ": something", fnf.ToString(), "#7");
#else
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName), "#7");
            Assert.IsFalse(fnf.ToString().IndexOf(Environment.NewLine) != -1, "#9");
#endif
        }
Ejemplo n.º 2
0
        public void Constructor4_Message_Empty()
        {
            FileNotFoundException fnf = null;

            fnf = new FileNotFoundException(string.Empty, "file.txt");

#if NET_2_0
            Assert.IsNotNull(fnf.Data, "#1");
#endif
            Assert.IsNotNull(fnf.FileName, "#2");
            Assert.AreEqual("file.txt", fnf.FileName, "#3");
            Assert.IsNull(fnf.InnerException, "#4");
            Assert.IsNotNull(fnf.Message, "#5");
            Assert.AreEqual(string.Empty, fnf.Message, "#6");
            Assert.IsNull(fnf.FusionLog, "#7");
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName
                                                    + ": " + Environment.NewLine), "#8");
#if NET_2_0
            Assert.IsTrue(fnf.ToString().IndexOf("'file.txt'") != -1, "#9");
            Assert.IsFalse(fnf.ToString().IndexOf("\"file.txt\"") != -1, "#10");
#else
            Assert.IsFalse(fnf.ToString().IndexOf("'file.txt'") != -1, "#9");
            Assert.IsTrue(fnf.ToString().IndexOf("\"file.txt\"") != -1, "#10");
#endif
        }
Ejemplo n.º 3
0
        public void GetResponse_File_DoesNotExist()
        {
            FileWebRequest req = (FileWebRequest)WebRequest.Create(_tempFileUri);

            try {
                req.GetResponse();
                Assert.Fail("#1");
            } catch (WebException ex) {
                Assert.AreEqual(typeof(WebException), ex.GetType(), "#1");
                Assert.IsNotNull(ex.Message, "#2");
#if !TARGET_JVM
                Assert.IsTrue(ex.Message.IndexOf("FileWebRequestTest.tmp") != -1, "#3");
                Assert.IsNull(ex.Response, "#4");
                Assert.IsNotNull(ex.InnerException, "#5");
#endif

#if ONLY_1_1
                FileNotFoundException fnf = ex.InnerException as FileNotFoundException;
                Assert.IsNotNull(fnf, "#6");
                Assert.AreEqual(typeof(FileNotFoundException), fnf.GetType(), "#7");
                Assert.IsNotNull(fnf.FileName, "#8");
                Assert.IsTrue(fnf.FileName.IndexOf("FileWebRequestTest.tmp") != -1, "#9");
                Assert.IsNotNull(fnf.Message, "#10");
                Assert.IsTrue(fnf.Message.IndexOf("FileWebRequestTest.tmp") != -1, "#11");
                Assert.IsNull(fnf.InnerException, "#12");
#endif
            }
        }
        public void Constructor4_FileName_Null()
        {
            FileNotFoundException fnf = new FileNotFoundException("message",
                                                                  (string)null);

            Assert.IsNotNull(fnf.Data, "#A1");
            Assert.IsNull(fnf.FileName, "#A2");
            Assert.IsNull(fnf.InnerException, "#A3");
            Assert.IsNotNull(fnf.Message, "#A4");
            Assert.AreEqual("message", fnf.Message, "#A5");
            Assert.IsNull(fnf.FusionLog, "#A6");

            Assert.AreEqual(fnf.GetType().FullName + ": message",
                            fnf.ToString(), "#A7");

            fnf = new FileNotFoundException(string.Empty, (string)null);

            Assert.IsNotNull(fnf.Data, "#B1");
            Assert.IsNull(fnf.FileName, "#B2");
            Assert.IsNull(fnf.InnerException, "#B3");
            Assert.IsNotNull(fnf.Message, "#B4");
            Assert.AreEqual(string.Empty, fnf.Message, "#B5");
            Assert.IsNull(fnf.FusionLog, "#B6");
            Assert.AreEqual(fnf.GetType().FullName + ": ",
                            fnf.ToString(), "#B7");
        }
        public void Constructor4_Message_Null()
        {
            FileNotFoundException fnf = null;

            fnf = new FileNotFoundException((string)null, "file.txt");

            Assert.IsNotNull(fnf.Data, "#A1");
            Assert.IsNotNull(fnf.FileName, "#A2");
            Assert.AreEqual("file.txt", fnf.FileName, "#A3");
            Assert.IsNull(fnf.InnerException, "#A4");
            Assert.IsNotNull(fnf.Message, "#A5");
            Assert.IsNull(fnf.FusionLog, "#A6");
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName
                                                    + ": "), "#A7");
            Assert.IsTrue(fnf.ToString().IndexOf(Environment.NewLine) != -1, "#A8");
            Assert.IsTrue(fnf.ToString().IndexOf("'file.txt'") != -1, "#A9");
            Assert.IsFalse(fnf.ToString().IndexOf("\"file.txt\"") != -1, "#A10");

            fnf = new FileNotFoundException((string)null, string.Empty);

            Assert.IsNotNull(fnf.Data, "#B1");
            Assert.IsNotNull(fnf.FileName, "#B2");
            Assert.AreEqual(string.Empty, fnf.FileName, "#B3");
            Assert.IsNull(fnf.InnerException, "#B4");
            // .NET 1.1: File or assembly name , or one of its dependencies ...
            // .NET 2.0: Could not load file or assembly '' or one of its ...
            Assert.IsNotNull(fnf.Message, "#B5");
            Assert.IsNull(fnf.FusionLog, "#B6");
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName
                                                    + ": "), "#B7");
            Assert.IsFalse(fnf.ToString().IndexOf(Environment.NewLine) != -1, "#B8");
            Assert.IsTrue(fnf.ToString().IndexOf("''") != -1, "#B9");
        }
Ejemplo n.º 6
0
        public void Erreur_FileNotFoundException_Bien_Traite()
        {
            FileNotFoundException ex = new FileNotFoundException("FileNotFound");

            GestionErreur.GerrerErreur(ex);
            msbs.Verify(mm => mm.ShowError(AxLanguage.Languages.REAplan_Erreur_Fichier + "\n" + AxLanguage.Languages.REAplan_Erreur_Call + "\n" + AxLanguage.Languages.REAplan_Erreur_NumeroTelephone));
            log.Verify(ll => ll.Error(ex.GetType().Name + " | " + ex.Message + " |" + ex.StackTrace));
        }
Ejemplo n.º 7
0
        public void Constructor2_Message_Empty()
        {
            FileNotFoundException fnf = new FileNotFoundException(string.Empty);

#if NET_2_0
            Assert.IsNotNull(fnf.Data, "#1");
#endif
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNull(fnf.InnerException, "#3");
            Assert.IsNotNull(fnf.Message, "#4");
            Assert.AreEqual(string.Empty, fnf.Message, "#5");
            Assert.IsNull(fnf.FusionLog, "#6");
#if TARGET_JVM
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": "), "#7");
#else
            Assert.AreEqual(fnf.GetType().FullName + ": ",
                            fnf.ToString(), "#7");
#endif
        }
        public void Constructor1()
        {
            FileNotFoundException fnf = new FileNotFoundException();

            Assert.IsNotNull(fnf.Data, "#1");
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNull(fnf.InnerException, "#3");
            Assert.IsNotNull(fnf.Message, "#4");              // Unable to find the specified file
            Assert.IsNull(fnf.FusionLog, "#5");
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName), "#6");
        }
        public void Constructor2_Message_Null()
        {
            FileNotFoundException fnf = new FileNotFoundException((string)null);

            Assert.IsNotNull(fnf.Data, "#1");
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNull(fnf.InnerException, "#3");
            Assert.IsNull(fnf.Message, "#4");
            Assert.IsNull(fnf.FusionLog, "#5");
            Assert.AreEqual(fnf.GetType().FullName + ": ",
                            fnf.ToString(), "#6");
        }
Ejemplo n.º 10
0
        public void Constructor3_Message_Empty()
        {
            ArithmeticException   ame = new ArithmeticException("something");
            FileNotFoundException fnf = new FileNotFoundException(string.Empty, ame);

#if NET_2_0
            Assert.IsNotNull(fnf.Data, "#1");
#endif
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNotNull(fnf.InnerException, "#3");
            Assert.AreSame(ame, fnf.InnerException, "#4");
            Assert.IsNotNull(fnf.Message, "#5");
            Assert.AreEqual(string.Empty, fnf.Message, "#6");
            Assert.IsNull(fnf.FusionLog, "#7");
#if TARGET_JVM
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ":  ---> "
                                                    + ame.GetType().FullName + ": something"), "#8");
#else
            Assert.AreEqual(fnf.GetType().FullName + ":  ---> "
                            + ame.GetType().FullName + ": something", fnf.ToString(), "#8");
#endif
        }
Ejemplo n.º 11
0
        public void Constructor2_Message_Null()
        {
            FileNotFoundException fnf = new FileNotFoundException((string)null);

#if NET_2_0
            Assert.IsNotNull(fnf.Data, "#1");
#endif
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNull(fnf.InnerException, "#3");
#if NET_2_0
            Assert.IsNull(fnf.Message, "#4");
#else
            Assert.IsNotNull(fnf.Message, "#4");              // File or assembly name (null), or ...
#endif
            Assert.IsNull(fnf.FusionLog, "#5");
#if NET_2_0
            Assert.AreEqual(fnf.GetType().FullName + ": ",
                            fnf.ToString(), "#6");
#else
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName), "#6");
#endif
        }
        public void Constructor4_FileNameAndMessage_Empty()
        {
            FileNotFoundException fnf = new FileNotFoundException(string.Empty,
                                                                  string.Empty);

            Assert.IsNotNull(fnf.Data, "#1");
            Assert.IsNotNull(fnf.FileName, "#2");
            Assert.AreEqual(string.Empty, fnf.FileName, "#3");
            Assert.IsNull(fnf.InnerException, "#4");
            Assert.IsNotNull(fnf.Message, "#5");
            Assert.AreEqual(string.Empty, fnf.Message, "#6");
            Assert.IsNull(fnf.FusionLog, "#7");
            Assert.AreEqual(fnf.GetType().FullName + ": ", fnf.ToString(), "#8");
        }
        public void Constructor3_Message_Null()
        {
            ArithmeticException   ame = new ArithmeticException("something");
            FileNotFoundException fnf = new FileNotFoundException((string)null, ame);

            Assert.IsNotNull(fnf.Data, "#1");
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNotNull(fnf.InnerException, "#3");
            Assert.AreSame(ame, fnf.InnerException, "#4");
            Assert.IsNull(fnf.Message, "#5");
            Assert.IsNull(fnf.FusionLog, "#6");
            Assert.AreEqual(fnf.GetType().FullName + ":  ---> "
                            + ame.GetType().FullName + ": something", fnf.ToString(), "#7");
        }
Ejemplo n.º 14
0
        public void Constructor4_FileName_Null()
        {
            FileNotFoundException fnf = new FileNotFoundException("message",
                                                                  (string)null);

#if NET_2_0
            Assert.IsNotNull(fnf.Data, "#A1");
#endif
            Assert.IsNull(fnf.FileName, "#A2");
            Assert.IsNull(fnf.InnerException, "#A3");
            Assert.IsNotNull(fnf.Message, "#A4");
            Assert.AreEqual("message", fnf.Message, "#A5");
            Assert.IsNull(fnf.FusionLog, "#A6");
#if TARGET_JVM
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": message"), "#A7");
#else
            Assert.AreEqual(fnf.GetType().FullName + ": message",
                            fnf.ToString(), "#A7");
#endif

            fnf = new FileNotFoundException(string.Empty, (string)null);

#if NET_2_0
            Assert.IsNotNull(fnf.Data, "#B1");
#endif
            Assert.IsNull(fnf.FileName, "#B2");
            Assert.IsNull(fnf.InnerException, "#B3");
            Assert.IsNotNull(fnf.Message, "#B4");
            Assert.AreEqual(string.Empty, fnf.Message, "#B5");
            Assert.IsNull(fnf.FusionLog, "#B6");
#if TARGET_JVM
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": "), "#B7");
#else
            Assert.AreEqual(fnf.GetType().FullName + ": ",
                            fnf.ToString(), "#B7");
#endif
        }
        public void Constructor4_FileNameAndMessage_Null()
        {
            FileNotFoundException fnf = new FileNotFoundException((string)null,
                                                                  (string)null);

            Assert.IsNotNull(fnf.Data, "#1");
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNull(fnf.InnerException, "#3");
            Assert.IsNull(fnf.Message, "#4");
            Assert.IsNull(fnf.FusionLog, "#5");
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName
                                                    + ": "), "#6");
            Assert.IsFalse(fnf.ToString().IndexOf(Environment.NewLine) != -1, "#7");
            Assert.IsFalse(fnf.ToString().IndexOf("''") != -1, "#8");
        }
Ejemplo n.º 16
0
        // public static TheDarkOwlLogger.TheDarkOwlLogger Bugger = new TheDarkOwlLogger.TheDarkOwlLogger(false, true, true, "WhiteTiger");
        public static void errorreport(Exception e)
        {
            NoNullAllowedException nonullallowedext = new NoNullAllowedException();

            System.Data.RowNotInTableException exrownotinTable = new RowNotInTableException();
            System.ArgumentOutOfRangeException excarg          = new ArgumentOutOfRangeException();
            System.IO.FileNotFoundException    filenotfound    = new FileNotFoundException();
            System.Xml.XmlException            xmlexc          = new XmlException();
            if ((e.GetType() != nonullallowedext.GetType()) && (e.GetType() != exrownotinTable.GetType()) &&
                (e.GetType() != excarg.GetType()) && (e.GetType() != filenotfound.GetType()) &&
                (e.GetType() != xmlexc.GetType()))
            {
                logman.TraceException(e.Message, e);
            }
        }
Ejemplo n.º 17
0
        public void Constructor2()
        {
            FileNotFoundException fnf = new FileNotFoundException("message");

#if NET_2_0
            Assert.IsNotNull(fnf.Data, "#1");
#endif
            Assert.IsNull(fnf.FileName, "#2");
            Assert.IsNull(fnf.InnerException, "#3");
            Assert.IsNotNull(fnf.Message, "#4");
            Assert.AreEqual("message", fnf.Message, "#5");
            Assert.IsNull(fnf.FusionLog, "#6");
            Assert.AreEqual(fnf.GetType().FullName + ": message",
                            fnf.ToString(), "#7");
        }
        public void Constructor4()
        {
            FileNotFoundException fnf = new FileNotFoundException("message",
                                                                  "file.txt");

            Assert.IsNotNull(fnf.Data, "#1");
            Assert.IsNotNull(fnf.FileName, "#2");
            Assert.AreEqual("file.txt", fnf.FileName, "#3");
            Assert.IsNull(fnf.InnerException, "#4");
            Assert.IsNotNull(fnf.Message, "#5");
            Assert.AreEqual("message", fnf.Message, "#6");
            Assert.IsNull(fnf.FusionLog, "#7");
            Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName
                                                    + ": message" + Environment.NewLine), "#8");
            Assert.IsTrue(fnf.ToString().IndexOf("'file.txt'") != -1, "#9");
            Assert.IsFalse(fnf.ToString().IndexOf("\"file.txt\"") != -1, "#9");
        }
Ejemplo n.º 19
0
        private void RemoveShapefile(FileNotFoundException ex)
        {
            MessageBox.Show(ex.Message + "\r\n" + ex.FileName, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
            string shapeName = new FileInfo(Path.ChangeExtension(ex.FileName, ".shp")).Name;

            winformsMap1.Overlays[0].Lock.EnterWriteLock();
            try
            {
                ((LayerOverlay)winformsMap1.Overlays[0]).Layers.Remove(shapeName);
            }
            finally
            {
                winformsMap1.Overlays[0].Lock.ExitWriteLock();
            }
            if (themeView.Items.Contains(shapeName))
            {
                themeView.Items.Remove(shapeName);
                themeView.SetupItems();
            }
        }
Ejemplo n.º 20
0
        public void DownloadInvoiceFile_WrongInvoiceId_CorrectExceptionOccured()
        {
            //Arrange
            string    sourceFilePath        = @"C:\Invoices\wrongid.xml";
            string    downloadingFilePath   = @"C:\Invoices\Downloads\00000000-0000-0000-0000-000000000000.xml";
            Exception expectedException     = null;
            var       fileNotFoundException = new FileNotFoundException();

            //Act
            try
            {
                InvoiceFileService.DownloadInvoiceFile("", sourceFilePath, downloadingFilePath);
            }
            catch (Exception ex)
            {
                expectedException = ex;
            }

            //Assert
            Assert.Equal(expectedException.GetType(), fileNotFoundException.GetType());
        }