Beispiel #1
0
        private void BusinessLogicModel_Reports_Invalid_Assembly(string assemblyFileName, string[] assemblyPaths, string[] referenceAssemblyPaths)
        {
            string logMessage = null;
            using (BusinessLogicModel model = new BusinessLogicModel(s => logMessage = s))
            {
                BusinessLogicData bld = new BusinessLogicData()
                {
                    AssemblyPaths = assemblyPaths,
                    ReferenceAssemblyPaths = referenceAssemblyPaths,
                    ContextTypeNames = new string[0],
                    Language = "C#"
                };

                // Format the expected message by duplicating the failure path
                string expectedMessage = null;
                try
                {
                    AssemblyName.GetAssemblyName(assemblyFileName);
                }
                catch (Exception ex)
                {
                    expectedMessage = string.Format(CultureInfo.CurrentCulture, Resources.BusinessLogicClass_Failed_Load, assemblyFileName, ex.Message);
                }

                model.Initialize(bld);

                // Asking for context should attempt to load assembly and log the result
                ContextData[] contextDataItems = model.GetContextDataItems();
                Assert.AreEqual(1, contextDataItems.Length, "Expected default context");
                Assert.AreEqual(expectedMessage, logMessage, "logger was not called");
            }
        }
Beispiel #2
0
 public void BusinessLogicModel_Throws_Not_Initialized()
 {
     string logMessage = null;
     using (BusinessLogicModel model = new BusinessLogicModel(s => logMessage = s))
     {
         ExceptionHelper.ExpectInvalidOperationException(() =>
         {
             // Asking it to perform any work will throw
            model.GetContextDataItems();
         }, Resources.BusinessLogicClass_Not_Initialized
         );
     }
 }
 public void BusinessLogicModel_Throws_Not_Initialized()
 {
     string logMessage = null;
     using (BusinessLogicModel model = new BusinessLogicModel(s => logMessage = s))
     {
         ExceptionHelper.ExpectInvalidOperationException(() =>
         {
             // Asking it to perform any work will throw
            model.GetContextDataItems();
         }, Resources.BusinessLogicClass_Not_Initialized
         );
     }
 }
Beispiel #4
0
        public void BusinessLogicModel_Reports_Invalid_Context()
        {
            string logMessage = null;
            using (BusinessLogicModel model = new BusinessLogicModel(s => logMessage = s))
            {
                BusinessLogicData bld = new BusinessLogicData()
                {
                    AssemblyPaths = new string[0],
                    ReferenceAssemblyPaths = new string[0],
                    ContextTypeNames = new string[] { typeof(string).AssemblyQualifiedName },
                    Language = "C#"
                };

                model.Initialize(bld);

                ContextData[] contextDataItems = model.GetContextDataItems();
                Assert.AreEqual(1, contextDataItems.Length, "Expected default context");

                string expectedMessage = string.Format(CultureInfo.CurrentCulture, Resources.BusinessLogicClass_InvalidContextType, typeof(string).FullName);
                Assert.AreEqual(expectedMessage, logMessage, "logger was not called");
            }
        }
        public void BusinessLogicModel_Reports_Invalid_Context()
        {
            string logMessage = null;
            using (BusinessLogicModel model = new BusinessLogicModel(s => logMessage = s))
            {
                BusinessLogicData bld = new BusinessLogicData()
                {
                    AssemblyPaths = new string[0],
                    ReferenceAssemblyPaths = new string[0],
                    ContextTypeNames = new string[] { typeof(string).AssemblyQualifiedName },
                    Language = "C#"
                };

                model.Initialize(bld);

                ContextData[] contextDataItems = model.GetContextDataItems();
                Assert.AreEqual(1, contextDataItems.Length, "Expected default context");

                string expectedMessage = string.Format(CultureInfo.CurrentCulture, Resources.BusinessLogicClass_InvalidContextType, typeof(string).FullName);
                Assert.AreEqual(expectedMessage, logMessage, "logger was not called");
            }
        }
        private void BusinessLogicModel_Reports_Invalid_Assembly(string assemblyFileName, string[] assemblyPaths, string[] referenceAssemblyPaths)
        {
            string logMessage = null;
            using (BusinessLogicModel model = new BusinessLogicModel(s => logMessage = s))
            {
                BusinessLogicData bld = new BusinessLogicData()
                {
                    AssemblyPaths = assemblyPaths,
                    ReferenceAssemblyPaths = referenceAssemblyPaths,
                    ContextTypeNames = new string[0],
                    Language = "C#"
                };

                // Format the expected message by duplicating the failure path
                string expectedMessage = null;
                try
                {
                    AssemblyName.GetAssemblyName(assemblyFileName);
                }
                catch (Exception ex)
                {
                    expectedMessage = string.Format(CultureInfo.CurrentCulture, Resources.BusinessLogicClass_Failed_Load, assemblyFileName, ex.Message);
                }

                model.Initialize(bld);

                // Asking for context should attempt to load assembly and log the result
                ContextData[] contextDataItems = model.GetContextDataItems();
                Assert.AreEqual(1, contextDataItems.Length, "Expected default context");
                Assert.AreEqual(expectedMessage, logMessage, "logger was not called");
            }
        }