Ejemplo n.º 1
0
        /// <summary>
        /// Retrieves the resource verifier for the specified assembly.
        /// </summary>
        /// <param name="assemblyFullName">The full name of the assembly to retrieve.</param>
        /// <returns>The resource verifier for the assembly.</returns>
        private static IStringResourceVerifier GetResourceVerifier(string assemblyFullName)
        {
            ExceptionUtilities.CheckStringArgumentIsNotNullOrEmpty(assemblyFullName, "assemblyFullName");

            IStringResourceVerifier verifier = null;

            // Resource lookup not supported on Silverlight or Phone platforms.
            if (!resourceVerifierCache.TryGetValue(assemblyFullName, out verifier))
            {
                Assembly assembly = Assembly.Load(new AssemblyName(assemblyFullName));
                var      lookup   = new ODataAssemblyResourceLookup(assembly);
                verifier = new StringResourceVerifier(lookup);
                resourceVerifierCache.Add(assemblyFullName, verifier);
            }

            return(verifier);
        }
Ejemplo n.º 2
0
        protected void VerifyThrowsException(Type exceptionType, Action action, string expectedErrorMessageResourceKey)
        {
            bool exceptionThrown = false;
            StringResourceVerifier stringResourceVerifier = null;

            if (!string.IsNullOrEmpty(expectedErrorMessageResourceKey))
            {
                stringResourceVerifier = new StringResourceVerifier(new AssemblyResourceLookup(typeof(IEdmModel).Assembly));
            }
            try
            {
                action();
            }
            catch (Exception ex)
            {
                exceptionThrown = true;
                Assert.AreEqual(exceptionType, ex.GetType(), "Unexpected Exception type!");
                if (stringResourceVerifier != null)
                {
                    Assert.IsTrue(stringResourceVerifier.IsMatch(expectedErrorMessageResourceKey, ex.Message, false), "Unexpected Exception string!");
                }
            }
            Assert.IsTrue(exceptionThrown, "Didn't throw exception!");
        }