예제 #1
0
        public void Dispose()
        {
            XpoTypesInfoHelper.Reset();
            XafTypesInfo.HardReset();
//            GC.Collect();
            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
            {
//                var settingsPath = $"{AppDomain.CurrentDomain.ApplicationPath()}\\TestRun.Settings";
//                while (!File.Exists(settingsPath)){
//                    var parent = new DirectoryInfo($"{Path.GetDirectoryName(settingsPath)}").Parent;
//                    if (parent == null){
//                        settingsPath = null;
//                        break;
//                    }
//                    settingsPath = $"{parent.FullName}\\TestRun.Settings";
//                }
//
//                if (settingsPath != null){
//                    var settings=Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(settingsPath);
//                    var fileName = $"{settings.TestArtifactsDirectory}\\TestsRun.zip";
//                    ZipFile.CreateFromDirectory(settings.TestArtifactsDirectory,fileName,CompressionLevel.NoCompression, false);
//                    TestContext.AddTestAttachment(fileName);
//                }
            }
        }
        ApplicationModulesManager GetApplicationModulesManager(PathInfo pathInfo)
        {
            string assemblyPath         = Path.GetDirectoryName(pathInfo.AssemblyPath);
            var    designerModelFactory = new DesignerModelFactory();

            ReflectionHelper.Reset();
            XafTypesInfo.HardReset();
            XpoTypesInfoHelper.ForceInitialize();
            if (pathInfo.IsApplicationModel)
            {
                _currentDomainOnAssemblyResolvePathInfo = pathInfo;
                AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomainOnAssemblyResolve;
                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;
                var applicationInstance = Activator.CreateInstance(Assembly.Load(pathInfo.AssemblyPath).GetTypes().First(type => typeof(XafApplication).IsAssignableFrom(type)));
                AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= CurrentDomainOnAssemblyResolve;
                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomainOnAssemblyResolve;
                _currentDomainOnAssemblyResolvePathInfo  = null;

                var configFileName = applicationInstance is WinApplication? pathInfo.AssemblyPath + ".config":Path.Combine(pathInfo.FullPath, "web.config");
                return(designerModelFactory.CreateModulesManager((XafApplication)applicationInstance, configFileName, Path.GetDirectoryName(pathInfo.AssemblyPath)));
            }
            var moduleFromFile = designerModelFactory.CreateModuleFromFile(pathInfo.AssemblyPath, assemblyPath);

            return(designerModelFactory.CreateModulesManager(moduleFromFile, pathInfo.AssemblyPath));
        }
예제 #3
0
 public void AfterContextCleanup()
 {
     Isolate.CleanUp();
     ReflectionHelper.Reset();
     XafTypesInfo.Reset();
     XafTypesInfo.HardReset();
     XpoTypesInfoHelper.GetXpoTypeInfoSource().ResetDictionary();
 }
예제 #4
0
 public void Dispose()
 {
     XpoTypesInfoHelper.Reset();
     XafTypesInfo.HardReset();
     if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
     {
         TestContext.AddTestAttachment(ReactiveLoggerService.RXLoggerLogPath);
     }
 }
예제 #5
0
        ApplicationModulesManager GetApplicationModulesManager(PathInfo pathInfo)
        {
            string assemblyPath         = Path.GetDirectoryName(pathInfo.AssemblyPath);
            var    designerModelFactory = new DesignerModelFactory();
            var    moduleFromFile       = designerModelFactory.CreateModuleFromFile(pathInfo.AssemblyPath, assemblyPath);

            ReflectionHelper.Reset();
            XafTypesInfo.HardReset();
            XpoTypesInfoHelper.ForceInitialize();
            return(designerModelFactory.CreateModulesManager(moduleFromFile, pathInfo.AssemblyPath));
        }
예제 #6
0
        ApplicationModulesManager GetApplicationModulesManager(PathInfo pathInfo)
        {
            var designerModelFactory = new DesignerModelFactory();

            ReflectionHelper.Reset();
            XafTypesInfo.HardReset();
            XpoTypesInfoHelper.ForceInitialize();
            if (pathInfo.IsApplicationModel)
            {
                var assembliesPath = Path.GetDirectoryName(pathInfo.AssemblyPath);
                var application    = designerModelFactory.CreateApplicationFromFile(pathInfo.AssemblyPath, assembliesPath);
                InitializeTypeInfoSources(application.Modules, assembliesPath);
                var applicationModulesManager = designerModelFactory.CreateModulesManager(application, null, assembliesPath);
                return(applicationModulesManager);
            }
            var moduleFromFile = designerModelFactory.CreateModuleFromFile(pathInfo.AssemblyPath, Path.GetDirectoryName(pathInfo.AssemblyPath));

            return(designerModelFactory.CreateModulesManager(moduleFromFile, pathInfo.AssemblyPath));
        }
예제 #7
0
        internal static IModelApplication CreateApplication(Type[] boModelTypes, Action <ITypesInfo>?customizeTypesInfo = null)
        {
            XafTypesInfo.HardReset();

            if (XafTypesInfo.Instance is TypesInfo typesInfo)
            {
                var store = typesInfo.FindEntityStore(typeof(NonPersistentTypeInfoSource));
                if (store is not null)
                {
                    foreach (var type in boModelTypes)
                    {
                        store.RegisterEntity(type);
                    }
                }
            }

            var modelManager = new ApplicationModelManager(null, true);

            var modules = new ModuleBase[]
            {
                new DXSystemModele(),
                new TestModule(boModelTypes, customizeTypesInfo)
            };

            foreach (var module in modules)
            {
                module.CustomizeTypesInfo(XafTypesInfo.Instance);
            }

            modelManager.Setup(
                XafTypesInfo.Instance,
                boModelTypes,
                modules,
                Enumerable.Empty <Controller>(),
                Enumerable.Empty <Type>(),
                Enumerable.Empty <string>(),
                null,
                null
                );

            return((IModelApplication)modelManager.CreateModelApplication(Enumerable.Empty <ModelApplicationBase>()));
        }
예제 #8
0
 protected BaseSpecs()
 {
     XafTypesInfo.HardReset();
 }
예제 #9
0
 public virtual void Dispose()
 {
     XpoTypesInfoHelper.Reset();
     XafTypesInfo.HardReset();
 }
예제 #10
0
        public void Dispose()
        {
            XpoTypesInfoHelper.Reset();
            XafTypesInfo.HardReset();
//            GC.Collect();
        }