コード例 #1
0
        public void AssemblyUtilities_LoadFromName()
        {
            AssemblyName name = typeof(System.Xml.XmlNode).Assembly.GetName();
            Assembly     a    = AssemblyUtilities.LoadAssembly(name, null);

            Assert.IsNotNull(a, "Failed to load assembly by name");
        }
コード例 #2
0
        public void AssemblyUtilities_Bad_Name_Logs()
        {
            string       logString            = null;
            string       expectedErrorMessage = null;
            string       fileName             = this.GetType().Assembly.Location + "x";
            AssemblyName asmName = null;

            try
            {
                asmName = AssemblyName.GetAssemblyName(fileName);
                Assembly.Load(asmName);
            }
            catch (Exception ex)
            {
                expectedErrorMessage = string.Format(CultureInfo.CurrentCulture, Resources.BusinessLogicClass_Failed_Load, fileName, ex.Message);
            }

            Assembly a = AssemblyUtilities.LoadAssembly(fileName, (s) => logString = s);

            Assert.IsNull(a, "Should have failed to load assembly by name");
            Assert.IsNotNull(logString, "logger was not called");
            Assert.AreEqual(expectedErrorMessage, logString, "unexpected error message");

            // Verify a null logger does not throw
            a = AssemblyUtilities.LoadAssembly(fileName, null);
            Assert.IsNull(a, "Should have failed to load assembly by name");
        }
コード例 #3
0
        public void AssemblyUtilities_LoadFromFile()
        {
            Assembly a = AssemblyUtilities.LoadAssembly(this.GetType().Assembly.Location, null);

            Assert.IsNotNull(a, "Failed to load assembly from file");
        }