public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call ToString on an empty exception class");

        try
        {
            BadImageFormatException ex = new BadImageFormatException();
            string expected = "System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.";
            string actual = ex.ToString();

            if (ex.ToString() == null)
            {
                TestLibrary.TestFramework.LogError("001.1", "ToString returns unexpected value");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] expected = " + expected + ", actual = " + actual);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
        public void Constructor4_FileName_Null()
        {
            BadImageFormatException bif = new BadImageFormatException("message",
                                                                      (string)null);

            Assert.IsNotNull(bif.Data, "#A1");
            Assert.IsNull(bif.FileName, "#A2");
            Assert.IsNull(bif.InnerException, "#A3");
            Assert.IsNotNull(bif.Message, "#A4");
            Assert.AreEqual("message", bif.Message, "#A5");
            Assert.IsNull(bif.FusionLog, "#A6");
            Assert.AreEqual(bif.GetType().FullName + ": message",
                            bif.ToString(), "#A7");

            bif = new BadImageFormatException(string.Empty, (string)null);

            Assert.IsNotNull(bif.Data, "#B1");
            Assert.IsNull(bif.FileName, "#B2");
            Assert.IsNull(bif.InnerException, "#B3");
            Assert.IsNotNull(bif.Message, "#B4");
            Assert.AreEqual(string.Empty, bif.Message, "#B5");
            Assert.IsNull(bif.FusionLog, "#B6");
            Assert.AreEqual(bif.GetType().FullName + ": ",
                            bif.ToString(), "#B7");
        }
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Call ToString on an exception class with message and inner is set");

        try
        {
            string    message          = TestLibrary.Generator.GetString(-55, false, 1, 50);
            Exception inner            = new Exception();
            BadImageFormatException ex = new BadImageFormatException(message, inner);
            string expected            = "System.BadImageFormatException: " + message + " ---> " + inner.ToString();
            string actual = ex.ToString();

            if (expected != actual)
            {
                TestLibrary.TestFramework.LogError("003.1", "ToString returns unexpected value");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] expected = " + expected + ", actual = " + actual);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
 public static void Ctor_String()
 {
     string message = "this is not the file you're looking for";
     var exception = new BadImageFormatException(message);
     ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_BADIMAGEFORMAT, message: message);
     Assert.Null(exception.FileName);
 }
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Call ToString on an exception class with message is set");

        try
        {
            string message = TestLibrary.Generator.GetString(-55, false, 1, 50);
            BadImageFormatException ex = new BadImageFormatException(message);
            string expected = "System.BadImageFormatException: " + message;
            string actual = ex.ToString();

            if (expected != actual)
            {
                TestLibrary.TestFramework.LogError("002.1", "ToString returns unexpected value");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] expected = " + expected + ", actual = " + actual);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Message should return correct value for instance with message and inner is set");

        try
        {
            string expected = TestLibrary.Generator.GetString(-55, false, 1, 256);
            BadImageFormatException ex = new BadImageFormatException(expected, new Exception());
            string actual = ex.Message;
            if (expected != actual)
            {
                TestLibrary.TestFramework.LogError("001.1", "Message returns wrong value for instance with message and inner is set");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] expected = " + expected + ", actual = " + actual);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
 private void WriteFusionLogWithAssert(StringBuilder sb)
 {
     for (System.Exception exception = this.Exception; exception != null; exception = exception.InnerException)
     {
         string fusionLog = null;
         string fileName  = null;
         FileNotFoundException exception2 = exception as FileNotFoundException;
         if (exception2 != null)
         {
             fusionLog = exception2.FusionLog;
             fileName  = exception2.FileName;
         }
         FileLoadException exception3 = exception as FileLoadException;
         if (exception3 != null)
         {
             fusionLog = exception3.FusionLog;
             fileName  = exception3.FileName;
         }
         BadImageFormatException exception4 = exception as BadImageFormatException;
         if (exception4 != null)
         {
             fusionLog = exception4.FusionLog;
             fileName  = exception4.FileName;
         }
         if (!string.IsNullOrEmpty(fusionLog))
         {
             this.WriteColoredSquare(sb, System.Web.SR.GetString("Error_Formatter_FusionLog"), System.Web.SR.GetString("Error_Formatter_FusionLogDesc", new object[] { fileName }), HttpUtility.HtmlEncode(fusionLog), false);
             return;
         }
     }
 }
Esempio n. 8
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Message should return correct value for instance with message and inner is set");

        try
        {
            string expected            = TestLibrary.Generator.GetString(-55, false, 1, 256);
            BadImageFormatException ex = new BadImageFormatException(expected, new Exception());
            string actual = ex.Message;
            if (expected != actual)
            {
                TestLibrary.TestFramework.LogError("001.1", "Message returns wrong value for instance with message and inner is set");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] expected = " + expected + ", actual = " + actual);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 9
0
        public SobrePage()
        {
            var titulo = new Label {
                FontSize       = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                FontAttributes = FontAttributes.Bold,
                Text           = "Histórico"
            };

            var historico = new Label {
                FontSize       = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                FontAttributes = FontAttributes.Bold,
                Text           = "O UNISAL é uma comunidade acadêmica formada por Docentes, Estudantes e pessoal administrativo, que promove de modo rigoroso, crítico e propositivo o desenvolvimento da pessoa humana e do patrimônio cultural da sociedade, mediante a pesquisa, a docência, a formação superior e contínua e os diversos serviços oferecidos às comunidades locais.\n\nA inspiração cristã, a natureza católica e a identidade salesiana do UNISAL supõem uma visão do mundo e da pessoa humana enraizadas e em sintonia com o Evangelho, e uma pedagogia fundamentada sobre os valores do Sistema Preventivo vivido por Dom Bosco.\n\nIsso implica, concretamente: um compromisso de unidade e comunhão com a Igreja; uma opção decidida em favor dos jovens; uma comunidade acadêmica com clara identidade salesiana; um projeto cultural cristão e salesianamente orientado e uma intencionalidade educativo-pastoral.\n\nA integração do conhecimento, o diálogo entre fé e razão, a busca contínua da verdade, a formação ética, o espírito de liberdade na caridade, o respeito recíproco e a promoção dos direitos humanos caracterizam e animam o UNISAL como centro de um saber que dá sabor ao estudo e à pesquisa e favorece a aquisição da verdadeira sabedoria de vida."
            };

            var unisal = new BadImageFormatException {
                Aspect = Aspect.AspectFit
            };

            unisal.Source = ImageSource.FormUri(new Uri("http:/unisal.br/wp-content/gallery/lorena_1;2-unisal-lorena.jpg"));

            Content = new ScrollView()
            {
                Content = new StackLayout()
                {
                }
            }
        }
        public void Constructor4_Message_Null()
        {
            BadImageFormatException bif = null;

            bif = new BadImageFormatException((string)null, "file.txt");

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

            bif = new BadImageFormatException((string)null, string.Empty);

            Assert.IsNotNull(bif.Data, "#B1");
            Assert.IsNotNull(bif.FileName, "#B2");
            Assert.AreEqual(string.Empty, bif.FileName, "#B3");
            Assert.IsNull(bif.InnerException, "#B4");
            // .NET 1.1: The format of the file 'file.txt' is invalid
            // .NET 2.0: Could not load file or assembly 'file.txt' or one of its ...
            Assert.IsNotNull(bif.Message, "#B5");
            Assert.IsNull(bif.FusionLog, "#B6");
            Assert.IsTrue(bif.ToString().StartsWith(bif.GetType().FullName
                                                    + ": "), "#B7");
            Assert.IsFalse(bif.ToString().IndexOf(Environment.NewLine) != -1, "#B8");
            Assert.IsTrue(bif.ToString().IndexOf("''") != -1, "#B9");
        }
        public void Constructor4_Message_Empty()
        {
            BadImageFormatException bif = null;

            bif = new BadImageFormatException(string.Empty, "file.txt");

#if NET_2_0
            Assert.IsNotNull(bif.Data, "#1");
#endif
            Assert.IsNotNull(bif.FileName, "#2");
            Assert.AreEqual("file.txt", bif.FileName, "#3");
            Assert.IsNull(bif.InnerException, "#4");
            Assert.IsNotNull(bif.Message, "#5");
            Assert.AreEqual(string.Empty, bif.Message, "#6");
            Assert.IsNull(bif.FusionLog, "#7");
            Assert.IsTrue(bif.ToString().StartsWith(bif.GetType().FullName
                                                    + ": " + Environment.NewLine), "#8");
#if NET_2_0
            Assert.IsTrue(bif.ToString().IndexOf("'file.txt'") != -1, "#9");
            Assert.IsFalse(bif.ToString().IndexOf("\"file.txt\"") != -1, "#10");
#else
            Assert.IsFalse(bif.ToString().IndexOf("'file.txt'") != -1, "#9");
            Assert.IsTrue(bif.ToString().IndexOf("\"file.txt\"") != -1, "#10");
#endif
        }
        /// <summary>
        /// This builds a string detailing the given exception.
        /// </summary>
        /// <param name="ex">The exceptions to describe.</param>
        /// <returns>A string detailing the given exception.</returns>
        public static string CreateTraceExceptionString(Exception ex)
        {
            if (ex == null)
            {
                return("\tNO EXCEPTION.");
            }

            StringBuilder stbException = new StringBuilder();

            stbException.AppendLine("Exception: ");
            stbException.AppendLine("Message: ").Append("\t");
            stbException.AppendLine(ex.Message);
            stbException.AppendLine("Full Trace: ").Append("\t");
            stbException.AppendLine(ex.ToString());
            if (ex is BadImageFormatException)
            {
                BadImageFormatException biex = (BadImageFormatException)ex;
                stbException.AppendFormat("File Name:\t{0}", biex.FileName).AppendLine();
                stbException.AppendFormat("Fusion Log:\t{0}", biex.FusionLog).AppendLine();
            }
            while (ex.InnerException != null)
            {
                ex = ex.InnerException;
                stbException.AppendLine("Inner Exception:");
                stbException.AppendLine(ex.ToString());
            }
            return(stbException.ToString());
        }
Esempio n. 13
0
 public void LoadAssemblyObject(string dllLocation)
 {
     try
     {
         ass = Assembly.LoadFrom(dllLocation);
     }
     catch (FileNotFoundException ex)
     {
         ProjectData.SetProjectError(ex);
         FileNotFoundException fnfe = ex;
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "DLL not found error:{1}{0}", fnfe.GetBaseException().ToString(), Environment.NewLine);
         ProjectData.ClearProjectError();
     }
     catch (ArgumentNullException ex2)
     {
         ProjectData.SetProjectError(ex2);
         ArgumentNullException ane = ex2;
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "DLL NULL error:{1}{0}", ane.GetBaseException().ToString(), Environment.NewLine);
         ProjectData.ClearProjectError();
     }
     catch (BadImageFormatException ex3)
     {
         ProjectData.SetProjectError(ex3);
         BadImageFormatException bife = ex3;
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "DLL not a valid assembly error:{1}{0}", bife.GetBaseException().ToString(), Environment.NewLine);
         ProjectData.ClearProjectError();
     }
 }
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call ToString on an empty exception class");

        try
        {
            BadImageFormatException ex = new BadImageFormatException();
            string expected            = "System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.";
            string actual = ex.ToString();

            if (ex.ToString() == null)
            {
                TestLibrary.TestFramework.LogError("001.1", "ToString returns unexpected value");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] expected = " + expected + ", actual = " + actual);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
Esempio n. 15
0
        public InicialPage()
        {
            var textoinicial = new Label {
                FontSize       = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                FontAttributes = FontAttributes.Bold,
                Text           = "Bem Vindos ao Unisal - Lorena"
            };

            var logo = new BadImageFormatException {
                Aspect            = Aspect.AspectFit,
                Source            = ImageSource.FromFile("logo.png"),
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };

            var email = new Button {
                Text = "*****@*****.**"
            };

            email.Clicked += (sender, e) => {
                Device.OpenUri(new Uri("mailto:[email protected]"));
            };

            Content = new ContentView()
            {
            }
        }
Esempio n. 16
0
 internal override TypeSymbol GetUnsupportedMetadataTypeSymbol(
     PEModuleSymbol moduleSymbol,
     BadImageFormatException exception
     )
 {
     return(new UnsupportedMetadataTypeSymbol(exception));
 }
        public void Constructor3_Message_Null()
        {
            ArithmeticException     ame = new ArithmeticException("something");
            BadImageFormatException bif = new BadImageFormatException((string)null, ame);

#if NET_2_0
            Assert.IsNotNull(bif.Data, "#1");
#endif
            Assert.IsNull(bif.FileName, "#2");
            Assert.IsNotNull(bif.InnerException, "#3");
            Assert.AreSame(ame, bif.InnerException, "#4");
#if NET_2_0
            Assert.IsNotNull(bif.Message, "#5"); // Could not load file or assembly '' ...
            Assert.IsTrue(bif.Message.IndexOf("''") != -1, "#6");
#else
            Assert.IsNotNull(bif.Message, "#5"); // Format of the executable (.exe) or library ...
            Assert.IsFalse(bif.Message.IndexOf("''") != -1, "#6");
#endif
            Assert.IsNull(bif.FusionLog, "#7");
            Assert.IsTrue(bif.ToString().StartsWith(bif.GetType().FullName), "#8");
            Assert.IsTrue(bif.ToString().IndexOf("---> " + ame.GetType().FullName) != -1, "#9");
#if !TARGET_JVM // ToString always has a stack trace under TARGET_JVM
            Assert.IsFalse(bif.ToString().IndexOf(Environment.NewLine) != -1, "#10");
#endif // TARGET_JVM
        }
        public static void Ctor_Empty()
        {
            var exception = new BadImageFormatException();

            ExceptionHelpers.ValidateExceptionProperties(exception, hResult: COR_E_BADIMAGEFORMAT, validateMessage: false);
            Assert.Null(exception.FileName);
        }
Esempio n. 19
0
 /// <summary>
 /// Displays the specified ex.
 /// </summary>
 /// <param name="ex">The ex.</param>
 public static void Display(BadImageFormatException ex)
 {
     ShowMessage("Selected assembly is either corrupted or its targeted framework version is not supported." +
                 " Please select non corrupted assembly targeted for .NET 3.5 or earlier framework versions.");
     LogTraceErrorMessage(string.Format(
                              "{0} Message= {1} \n Stacktrace = {2} \n InnerException= {3}",
                              DateTime.Now, ex.Message, ex.StackTrace, ex.InnerException));
 }
        public static void Ctor_String()
        {
            string message   = "this is not the file you're looking for";
            var    exception = new BadImageFormatException(message);

            ExceptionHelpers.ValidateExceptionProperties(exception, hResult: COR_E_BADIMAGEFORMAT, message: message);
            Assert.Null(exception.FileName);
        }
 public static void Ctor_String_Exception()
 {
     string message = "this is not the file you're looking for";
     var innerException = new Exception("Inner exception");
     var exception = new BadImageFormatException(message, innerException);
     ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_BADIMAGEFORMAT, innerException: innerException, message: message);
     Assert.Equal(null, exception.FileName);
 }
Esempio n. 22
0
        public void GetFusionLog_Pass()
        {
            BadImageFormatException fle = new BadImageFormatException("message", "filename");

            Assert.AreEqual("message", fle.Message, "Message");
            Assert.AreEqual("filename", fle.FileName, "FileName");
            Assert.IsNull(fle.FusionLog, "FusionLog");
            // note: ToString doesn't work in this case
        }
        public static void Ctor_String_Exception()
        {
            string message        = "this is not the file you're looking for";
            var    innerException = new Exception("Inner exception");
            var    exception      = new BadImageFormatException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_BADIMAGEFORMAT, innerException: innerException, message: message);
            Assert.Null(exception.FileName);
        }
        public static void Ctor_String_String()
        {
            string message   = "this is not the file you're looking for";
            string fileName  = "file.txt";
            var    exception = new BadImageFormatException(message, fileName);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_BADIMAGEFORMAT, message: message);
            Assert.Equal(fileName, exception.FileName);
        }
        public static void FusionLogTest()
        {
            string message        = "this is not the file you're looking for";
            string fileName       = "file.txt";
            var    innerException = new Exception("Inner exception");
            var    exception      = new BadImageFormatException(message, fileName, innerException);

            Assert.Null(exception.FusionLog);
        }
Esempio n. 26
0
        public void GetFusionLog_Fail_ControlPolicy()
        {
            BadImageFormatException fle = new BadImageFormatException();

            Assert.IsNull(fle.FusionLog, "FusionLog");
            // we don't have to throw the exception to have FusionLog
            // informations restricted (even if there could be no
            // data in this state).
        }
Esempio n. 27
0
        public void NoRestriction()
        {
            BadImageFormatException fle = new BadImageFormatException("message", "filename",
                                                                      new BadImageFormatException("inner message", "inner filename"));

            Assert.AreEqual("message", fle.Message, "Message");
            Assert.AreEqual("filename", fle.FileName, "FileName");
            Assert.IsNull(fle.FusionLog, "FusionLog");
            Assert.IsNotNull(fle.ToString(), "ToString");
        }
Esempio n. 28
0
 private static void ReportBadImageFormatErrorLoadingAssembly(BadImageFormatException ex)
 {
     MessageBox.Show(
         string.Format(
             CultureInfo.CurrentCulture,
             Properties.Resources.BadImageExceptionWhenLoading,
             ex.Message),
         Properties.Resources.ErrorLoadingAssembly,
         MessageBoxButton.OK);
 }
Esempio n. 29
0
        private static bool handleBadImageFormat(BadImageFormatException e)
        {
            if (!requiredDlls.Contains(e.FileName) && !requiredDlls.Contains(e.FileName + @".dll"))
            {
                return(false);
            }

            Repair(true, e);
            return(true);
        }
Esempio n. 30
0
        public void Constructor2_Message_Null()
        {
            BadImageFormatException bif = new BadImageFormatException((string)null);

            Assert.IsNotNull(bif.Data, "#1");
            Assert.IsNull(bif.FileName, "#2");
            Assert.IsNull(bif.InnerException, "#3");
            Assert.IsNotNull(bif.Message, "#4");
            Assert.IsNull(bif.FusionLog, "#5");
            Assert.IsTrue(bif.ToString().StartsWith(bif.GetType().FullName), "#6");
        }
        public void Constructor1()
        {
            BadImageFormatException bif = new BadImageFormatException();

            Assert.IsNotNull(bif.Data, "#1");
            Assert.IsNull(bif.FileName, "#2");
            Assert.IsNull(bif.InnerException, "#3");
            Assert.IsNotNull(bif.Message, "#4");              // Format of the executable (.exe) or library (.dll) is invalid
            Assert.IsNull(bif.FusionLog, "#5");
            Assert.IsTrue(bif.ToString().StartsWith(bif.GetType().FullName), "#6");
        }
Esempio n. 32
0
        public void FullRestriction()
        {
            BadImageFormatException fle = new BadImageFormatException("message", "filename",
                                                                      new BadImageFormatException("inner message", "inner filename"));

            Assert.AreEqual("message", fle.Message, "Message");
            Assert.AreEqual("filename", fle.FileName, "FileName");
            Assert.IsNull(fle.FusionLog, "FusionLog");
            // ToString doesn't work in this case and strangely throws a BadImageFormatException
            Assert.IsNotNull(fle.ToString(), "ToString");
        }
        public void CanGenerateDataListFromBadImageFormatException()
        {
            // Arrange
            var badImageFormatException = new BadImageFormatException("message", "fileName");

            // Act
            var result = badImageFormatException.ToDataList();

            // Assert
            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result.Any(r => r.Key == "BadImageFormatException.FileName" && r.Value == "fileName"));
        }
        public void Constructor2_Message_Null()
        {
            BadImageFormatException bif = new BadImageFormatException((string)null);

            Assert.IsNotNull(bif.Data, "#1");
            Assert.IsNull(bif.FileName, "#2");
            Assert.IsNull(bif.InnerException, "#3");
            Assert.IsNotNull(bif.Message, "#4");              // Could not load file or assembly '' ...
            Assert.IsTrue(bif.Message.IndexOf("''") != -1, "#5");
            Assert.IsNull(bif.FusionLog, "#5");
            Assert.IsTrue(bif.ToString().StartsWith(bif.GetType().FullName), "#6");
            Assert.IsTrue(bif.ToString().IndexOf("''") != -1, "#7");
        }
        public void Constructor2_Message_Empty()
        {
            BadImageFormatException bif = new BadImageFormatException(string.Empty);

            Assert.IsNotNull(bif.Data, "#1");
            Assert.IsNull(bif.FileName, "#2");
            Assert.IsNull(bif.InnerException, "#3");
            Assert.IsNotNull(bif.Message, "#4");
            Assert.AreEqual(string.Empty, bif.Message, "#5");
            Assert.IsNull(bif.FusionLog, "#6");
            Assert.AreEqual(bif.GetType().FullName + ": ",
                            bif.ToString(), "#7");
        }
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call ctor to create a new instance");

        try
        {
            Exception inner = new Exception();
            BadImageFormatException ex = new BadImageFormatException(TestLibrary.Generator.GetString(-55, false, 1, 256), inner);
            if (ex == null)
            {
                TestLibrary.TestFramework.LogError("001.1", "Calling ctor returns null reference");
                retVal = false;
            }

            if (!(ex is BadImageFormatException))
            {
                TestLibrary.TestFramework.LogError("001.2", "Calling ctor returns non BadImageFormatException instance");
                retVal = false;
            }

            if (ex.InnerException != inner)
            {
                TestLibrary.TestFramework.LogError("001.3", "Calling ctor can not set InnerException property");
                retVal = false;
            }

            // check we can throw this instance
            throw ex;
        }
        catch (BadImageFormatException)
        {
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Call ctor to create a new instance with message and innerException set to null");

        try
        {
            Exception inner = null;
            BadImageFormatException ex = new BadImageFormatException(null, inner);
            if (ex == null)
            {
                TestLibrary.TestFramework.LogError("002.1", "Calling ctor returns null reference");
                retVal = false;
            }

            if (!(ex is BadImageFormatException))
            {
                TestLibrary.TestFramework.LogError("002.2", "Calling ctor returns non BadImageFormatException instance");
                retVal = false;
            }

            if (ex.InnerException != inner)
            {
                TestLibrary.TestFramework.LogError("002.3", "Calling ctor can not set InnerException property");
                retVal = false;
            }

            // check we can throw this instance
            throw ex;
        }
        catch (BadImageFormatException)
        {
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
        public static void ToStringTest()
        {
            string message = "this is not the file you're looking for";
            string fileName = "file.txt";
            var innerException = new Exception("Inner exception");
            var exception = new BadImageFormatException(message, fileName, innerException);

            var toString = exception.ToString();
            Assert.Contains(": " + message, toString);
            Assert.Contains(": '" + fileName + "'", toString);
            Assert.Contains("---> " + innerException.ToString(), toString);

            // set the stack trace
            try { throw exception; }
            catch
            {
                Assert.False(string.IsNullOrEmpty(exception.StackTrace));
                Assert.Contains(exception.StackTrace, exception.ToString());
            }
        }
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Message should not return null reference for empty instance");

        try
        {
            BadImageFormatException ex = new BadImageFormatException();
            if (ex.Message == null)
            {
                TestLibrary.TestFramework.LogError("001.1", "Message returns null reference for empty instance");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call ctor to create a new instance");

        try
        {
            BadImageFormatException ex = new BadImageFormatException();
            if (ex == null)
            {
                TestLibrary.TestFramework.LogError("001.1", "Calling ctor returns null reference");
                retVal = false;
            }

            if (!(ex is BadImageFormatException))
            {
                TestLibrary.TestFramework.LogError("001.2", "Calling ctor returns non BadImageFormatException instance");
                retVal = false;
            }

            // check we can throw this instance
            throw ex;
        }
        catch (BadImageFormatException)
        {
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
 public static void Ctor_Empty()
 {
     var exception = new BadImageFormatException();
     ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_BADIMAGEFORMAT, validateMessage: false);
     Assert.Null(exception.FileName);
 }
        public static void FusionLogTest()
        {
            string message = "this is not the file you're looking for";
            string fileName = "file.txt";
            var innerException = new Exception("Inner exception");
            var exception = new BadImageFormatException(message, fileName, innerException);

            Assert.Null(exception.FusionLog);
        }
	// Test the BadImageFormatException class.
	public void TestBadImageFormatException()
			{
				BadImageFormatException e;
				ExceptionTester.CheckMain(typeof(BadImageFormatException),
										  unchecked((int)0x8007000b));
				e = new BadImageFormatException();
				AssertNull("BadImageFormatException (1)", e.FileName);
				e = new BadImageFormatException("msg");
				AssertNull("BadImageFormatException (2)", e.FileName);
				e = new BadImageFormatException("msg", "file");
				AssertEquals("BadImageFormatException (3)", "file", e.FileName);
				e = new BadImageFormatException("msg", "file", e);
				AssertEquals("BadImageFormatException (4)", "file", e.FileName);
			}