Ejemplo n.º 1
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Call ctor with rand message");

        try
        {
            string expected = TestLibrary.Generator.GetString(-55, false, 1, 256);
            MissingManifestResourceException ex = new MissingManifestResourceException(expected);
            if (null == ex)
            {
                TestLibrary.TestFramework.LogError("003.1", "Calling ctor will rand message returns null reference");
                retVal = false;
            }

            string message = ex.Message;
            // using default message
            if (message != expected)
            {
                TestLibrary.TestFramework.LogError("003.2", "Calling ctor will rand message returns null message");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLES] message = " + message + ", expected = " + expected);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
Ejemplo n.º 2
0
        // ICU4N: Avoid static constructor by initializing inline
        private static CollationTailoring LoadCollationTailoring(out Exception exception)
        {
            // Corresponds to C++ load() function.
            CollationTailoring t  = null;
            Exception          e2 = null;

            try
            {
                ByteBuffer         bytes = ICUBinary.GetRequiredData("coll/ucadata.icu");
                CollationTailoring t2    = new CollationTailoring(null);
                CollationDataReader.Read(null, bytes, t2);
                // Keep t=null until after the root data has been read completely.
                // Otherwise we would set a non-null root object if the data reader throws an exception.
                t = t2;
            }
            catch (IOException e)
            {
                e2 = new MissingManifestResourceException(
                    "IOException while reading CLDR root data, " +
                    "type: CollationRoot, bundle: " + ICUData.IcuBundle + "/coll/ucadata.icu", e);
            }
            catch (Exception e)
            {
                e2 = e;
            }
            exception = e2;
            return(t);
        }
        public void Serialization()
        {
            const string message = "FATAL ERROR: The pizza could not be found.";
            var          ex      = new MissingManifestResourceException(message);

            BinaryFormatterHelpers.AssertRoundtrips(ex);
        }
Ejemplo n.º 4
0
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Call ctor with string.Empty");

        try
        {
            MissingManifestResourceException ex = new MissingManifestResourceException(string.Empty);
            if (null == ex)
            {
                TestLibrary.TestFramework.LogError("002.1", "Calling ctor will string.Empty returns null reference");
                retVal = false;
            }

            string message = ex.Message;
            // using default message
            if (message == null)
            {
                TestLibrary.TestFramework.LogError("002.2", "Calling ctor will string.Empty returns null message");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return(retVal);
    }
        public static void ConstructorWithMessage()
        {
            string message = "message";
            MissingManifestResourceException mmre = new MissingManifestResourceException(message);

            Assert.Equal(message, mmre.Message);
        }
    public bool PosTest2()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest2: Call ctor with string.Empty");

        try
        {
            MissingManifestResourceException ex = new MissingManifestResourceException(string.Empty);
            if (null == ex)
            {
                TestLibrary.TestFramework.LogError("002.1", "Calling ctor will string.Empty returns null reference");
                retVal = false;
            }

            string message = ex.Message;
            // using default message
            if (message == null)
            {
                TestLibrary.TestFramework.LogError("002.2", "Calling ctor will string.Empty returns null message");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Ejemplo n.º 7
0
        static CollationRoot()
        {  // Corresponds to C++ load() function.
            CollationTailoring t  = null;
            Exception          e2 = null;

            try
            {
                // ICU4N specific - passing in assembly name so we resolve to this assembly rather than ICU4N.dll
                ByteBuffer         bytes = ICUBinary.GetRequiredData(typeof(CollationRoot).GetTypeInfo().Assembly, null, "coll/ucadata.icu");
                CollationTailoring t2    = new CollationTailoring(null);
                CollationDataReader.Read(null, bytes, t2);
                // Keep t=null until after the root data has been read completely.
                // Otherwise we would set a non-null root object if the data reader throws an exception.
                t = t2;
            }
            catch (IOException e)
            {
                e2 = new MissingManifestResourceException(
                    "IOException while reading CLDR root data, " +
                    "type: CollationRoot, bundle: " + ICUData.ICU_BUNDLE + "/coll/ucadata.icu", e);
            }
            catch (Exception e)
            {
                e2 = e;
            }
            rootSingleton = t;
            exception     = e2;
        }
 public static void ConstructorWithMessageAndInnerException()
 {
     string message = "message";
     Exception innerException = new Exception();
     MissingManifestResourceException mmre = new MissingManifestResourceException(message, innerException);
     Assert.Equal(message, mmre.Message);
     Assert.Same(innerException, mmre.InnerException);
 }
        public static void ConstructorWithMessageAndInnerException()
        {
            string    message        = "message";
            Exception innerException = new Exception();
            MissingManifestResourceException mmre = new MissingManifestResourceException(message, innerException);

            Assert.Equal(message, mmre.Message);
            Assert.Same(innerException, mmre.InnerException);
        }
Ejemplo n.º 10
0
 public static void ExpectMissingManifestResourceException()
 {
     MissingManifestResourceException e = Assert.Throws<MissingManifestResourceException> (() =>
     {
         Type resourceType = typeof(Resources.TestClassWithoutNeutralResources);
         ResourceManager resourceManager = new ResourceManager(resourceType);
         string actual = resourceManager.GetString("Any");
     });
     Assert.NotNull(e.Message);
 }
Ejemplo n.º 11
0
 static UPropertyAliases()
 {
     try
     {
         instance = new UPropertyAliases();
     }
     catch (IOException e)
     {
         //CLOVER:OFF
         MissingManifestResourceException mre = new MissingManifestResourceException(
             "Could not construct UPropertyAliases. Missing pnames.icu", e);
         throw mre;
         //CLOVER:ON
     }
 }
Ejemplo n.º 12
0
        } = LoadSingletonInstance();                                                             // ICU4N: Avoid static constructor by initializing inline

        private static UPropertyAliases LoadSingletonInstance()
        {
            try
            {
                return(new UPropertyAliases());
            }
            catch (IOException e)
            {
                ////CLOVER:OFF
                MissingManifestResourceException mre = new MissingManifestResourceException(
                    "Could not construct UPropertyAliases. Missing pnames.icu", e);
                throw mre;
                ////CLOVER:ON
            }
        }
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Call ctor with null");

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

            string message = ex.Message;
            // using default message
            if (message == null)
            {
                TestLibrary.TestFramework.LogError("001.2", "Calling ctor will null returns null message");
                retVal = false;
            }

            Exception innerException = ex.InnerException;
            // using default message
            if (innerException != null)
            {
                TestLibrary.TestFramework.LogError("001.3", "Calling ctor will null returns not null innerException");
                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 with null");

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

            string message = ex.Message;
            // using default message
            if (message == null)
            {
                TestLibrary.TestFramework.LogError("001.2", "Calling ctor will null returns null message");
                retVal = false;
            }

            Exception innerException = ex.InnerException;
            // using default message
            if (innerException != null)
            {
                TestLibrary.TestFramework.LogError("001.3", "Calling ctor will null returns not null innerException");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
Ejemplo n.º 15
0
    public bool PosTest1()
    {
        bool retVal = true;

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

        try
        {
            MissingManifestResourceException ex = new MissingManifestResourceException();
            if (ex == null)
            {
                TestLibrary.TestFramework.LogError("001.1", "Calling ctor returns null reference");
                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
        {
            MissingManifestResourceException ex = new MissingManifestResourceException();
            if (ex == null)
            {
                TestLibrary.TestFramework.LogError("001.1", "Calling ctor returns null reference");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

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

        TestLibrary.TestFramework.BeginScenario("PosTest3: Call ctor with rand message");

        try
        {
            string expected = TestLibrary.Generator.GetString(-55, false, 1, 256);
            Exception expectedException = new TestException();
            MissingManifestResourceException ex = new MissingManifestResourceException(expected, expectedException);
            if (null == ex)
            {
                TestLibrary.TestFramework.LogError("003.1", "Calling ctor will rand message returns null reference");
                retVal = false;
            }

            string message = ex.Message;
            // using default message
            if (message != expected)
            {
                TestLibrary.TestFramework.LogError("003.2", "Calling ctor will rand message returns null message");
                TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLES] message = " + message + ", expected = " + expected);
                retVal = false;
            }

            Exception innerException = ex.InnerException;
            // using default message
            if (innerException != expectedException)
            {
                TestLibrary.TestFramework.LogError("003.3", "Calling ctor will string.Empty returns wrong inner exception");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.0", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
 public void Serialization()
 {
     const string message = "FATAL ERROR: The pizza could not be found.";
     var ex = new MissingManifestResourceException(message);
     BinaryFormatterHelpers.AssertRoundtrips(ex);
 }
 public static void ConstructorSimple()
 {
     MissingManifestResourceException mmre = new MissingManifestResourceException();
     Assert.NotNull(mmre.Message);
 }
 public static void ConstructorWithMessage()
 {
     string message = "message";
     MissingManifestResourceException mmre = new MissingManifestResourceException(message);
     Assert.Equal(message, mmre.Message);
 }
        public static void ConstructorSimple()
        {
            MissingManifestResourceException mmre = new MissingManifestResourceException();

            Assert.NotNull(mmre.Message);
        }