示例#1
0
        public static void SetupComponentTests(TestContext context)
        {
            NLog.LogManager.Configuration = new NLog.Config.LoggingConfiguration();

            string name    = "TraceLab.Core.Components.Test.MockComponent";
            string assmDir = System.IO.Path.Combine(System.Environment.CurrentDirectory, Guid.NewGuid().ToString());

            System.IO.Directory.CreateDirectory(assmDir);

            //AssemblyPath = System.IO.Path.Combine(System.Environment.CurrentDirectory, "TraceLab.Core.Components.Test.MockComponent.DLL");
            MockComponentGenerator gen = new MockComponentGenerator(assmDir, name);

            gen.Generate();
            AssemblyPath = gen.AssemblyPath;

            // Ensure that the assembly is not already loaded
            foreach (System.Reflection.Assembly assm in AppDomain.CurrentDomain.GetAssemblies())
            {
                try
                {
                    //Dynamic libraries generated dynamically in the process cannot access location - it would throw NotSupportedException
                    //for example runtime assemblies Microsoft.GeneratedCode of xml serializers
                    if (assm.IsDynamic == false)
                    {
                        Assert.IsFalse(assm.Location.Equals(AssemblyPath, StringComparison.CurrentCultureIgnoreCase));
                    }
                }
                catch (NotSupportedException)
                {
                    if (System.Diagnostics.Debugger.IsAttached)
                    {
                        System.Diagnostics.Debugger.Break();
                    }
                    throw;
                }
            }

            string dir   = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var    types = System.IO.Path.Combine(dir, "Types");

            System.IO.Directory.CreateDirectory(types);
            List <string> typesDir = new List <string>();

            typesDir.Add(types);
            TraceLab.Core.Workspaces.WorkspaceManager.InitWorkspace(typesDir, System.IO.Path.Combine(dir, "workspace"), System.IO.Path.Combine(dir, "cache"));
        }
        public static void SetupComponentTests(TestContext context)
        {
            NLog.LogManager.Configuration = new NLog.Config.LoggingConfiguration();

            string name = "TraceLab.Core.Components.Test.MockComponent";
            string assmDir = System.IO.Path.Combine(System.Environment.CurrentDirectory, Guid.NewGuid().ToString());
            System.IO.Directory.CreateDirectory(assmDir);

            //AssemblyPath = System.IO.Path.Combine(System.Environment.CurrentDirectory, "TraceLab.Core.Components.Test.MockComponent.DLL");
            MockComponentGenerator gen = new MockComponentGenerator(assmDir, name);
            gen.Generate();
            AssemblyPath = gen.AssemblyPath;

            // Ensure that the assembly is not already loaded
            foreach (System.Reflection.Assembly assm in AppDomain.CurrentDomain.GetAssemblies())
            {
                try
                {
                    //Dynamic libraries generated dynamically in the process cannot access location - it would throw NotSupportedException
                    //for example runtime assemblies Microsoft.GeneratedCode of xml serializers
                    if (assm.IsDynamic == false)
                    {
                        Assert.IsFalse(assm.Location.Equals(AssemblyPath, StringComparison.CurrentCultureIgnoreCase));
                    }
                }
                catch (NotSupportedException)
                {
                    if (System.Diagnostics.Debugger.IsAttached)
                    {
                        System.Diagnostics.Debugger.Break();
                    }
                    throw;
                }
            }

            string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var types = System.IO.Path.Combine(dir, "Types");
            System.IO.Directory.CreateDirectory(types);
            List<string> typesDir = new List<string>();
            typesDir.Add(types);
            TraceLab.Core.Workspaces.WorkspaceManager.InitWorkspace(typesDir, System.IO.Path.Combine(dir, "workspace"), System.IO.Path.Combine(dir, "cache"));
        }