Esempio n. 1
0
        public void Pickers_ShouldAllHaveValidExamples_MatchingRegex(Type pickerType)
        {
            var oc = new ObjectConstructor();

            var mem = new MemoryDataExportRepository();

            mem.MEF = MEF;

            //create some objects that the examples can successfully reference
            new Catalogue(mem.CatalogueRepository, "mycata1"); //ID = 1
            new Catalogue(mem.CatalogueRepository, "mycata2"); //ID = 2
            new Catalogue(mem.CatalogueRepository, "mycata3"); //ID = 3

            PickObjectBase picker = (PickObjectBase)oc.Construct(pickerType, GetActivator(new RepositoryProvider(mem)));

            Assert.IsNotEmpty(picker.Help, "No Help for picker {0}", picker);
            Assert.IsNotEmpty(picker.Format, "No Format for picker {0}", picker);
            Assert.IsNotNull(picker.Examples, "No Examples for picker {0}", picker);
            Assert.IsNotEmpty(picker.Examples, "No Examples for picker {0}", picker);

            foreach (var example in picker.Examples)
            {
                //examples should be matched by the picker!
                Assert.IsTrue(picker.IsMatch(example, 0), "Example of picker '{0}' did not match the regex,listed example is '{1}'", picker, example);

                var result = picker.Parse(example, 0);

                Assert.IsNotNull(result);
            }
        }
Esempio n. 2
0
        public TestActivateItems(UITests uiTests, MemoryDataExportRepository repo) : base(new RepositoryProvider(repo), new ToMemoryCheckNotifier())
        {
            _uiTests   = uiTests;
            Results    = new TestActivateItemsResults();
            RefreshBus = new RefreshBus();

            //don't load the comment store for every single test
            if (_commentStore == null)
            {
                _commentStore = new CommentStore();
                _commentStore.ReadComments(TestContext.CurrentContext.TestDirectory);
            }

            CommentStore = _commentStore;

            CoreChildProvider  = new DataExportChildProvider(RepositoryLocator, null, Results);
            CoreIconProvider   = new DataExportIconProvider(RepositoryLocator, null);
            FavouritesProvider = new FavouritesProvider(this, repo.CatalogueRepository);

            _problemProviders = new List <IProblemProvider>(new IProblemProvider[]
            {
                new CatalogueProblemProvider(),
                new DataExportProblemProvider()
            });

            PluginUserInterfaces = new List <IPluginUserInterface>();
        }
        public void TestOrphanCic()
        {
            var memory = new MemoryDataExportRepository();
            var cic    = new CohortIdentificationConfiguration(memory, "Mycic");
            var p      = new Project(memory, "my proj");

            p.AssociateWithCohortIdentification(cic);

            //fetch the instance
            var cicAssoc = memory.GetAllObjects <ProjectCohortIdentificationConfigurationAssociation>().Single();

            //relationship from p should resolve to the association link
            Assert.AreEqual(cicAssoc, p.ProjectCohortIdentificationConfigurationAssociations[0]);

            //relationship from p should resolve to the cic
            Assert.AreEqual(cic, p.GetAssociatedCohortIdentificationConfigurations()[0]);

            //in order to make it an orphan we have to suppress the system default behaviour of cascading across the deletion
            var obscure = memory.ObscureDependencyFinder as CatalogueObscureDependencyFinder;

            if (obscure != null)
            {
                obscure.OtherDependencyFinders.Clear();
            }

            //make the assoc an orphan
            cic.DeleteInDatabase();
            cicAssoc.ClearAllInjections();

            //assoc should still exist
            Assert.AreEqual(cicAssoc, p.ProjectCohortIdentificationConfigurationAssociations[0]);
            Assert.IsNull(p.ProjectCohortIdentificationConfigurationAssociations[0].CohortIdentificationConfiguration);

            //relationship from p should resolve to the cic
            Assert.IsEmpty(p.GetAssociatedCohortIdentificationConfigurations());

            //error should be reported in top right of program
            var ex = Assert.Throws <Exception>(() => new DataExportChildProvider(new RepositoryProvider(memory), null, new ThrowImmediatelyCheckNotifier(), null));

            StringAssert.IsMatch(@"Failed to find Associated Cohort Identification Configuration with ID \d+ which was supposed to be associated with my proj", ex.Message);

            //but UI should still respond
            var childProvider = new DataExportChildProvider(new RepositoryProvider(memory), null, new IgnoreAllErrorsCheckNotifier(), null);

            //the orphan cic should not appear in the tree view under Project=>Cohorts=>Associated Cics
            var cohorts = childProvider.GetChildren(p).OfType <ProjectCohortsNode>().Single();
            var cics    = childProvider.GetChildren(cohorts).OfType <ProjectCohortIdentificationConfigurationAssociationsNode>().First();

            Assert.IsEmpty(childProvider.GetChildren(cics));
        }
Esempio n. 4
0
        private LoadMetadata ShareToNewRepository(LoadMetadata lmd)
        {
            var gatherer = new Gatherer(RepositoryLocator);

            Assert.IsTrue(gatherer.CanGatherDependencies(lmd));
            var rootObj = gatherer.GatherDependencies(lmd);

            var sm = new ShareManager(RepositoryLocator, null);
            var shareDefinition = rootObj.ToShareDefinitionWithChildren(sm);

            var repo2 = new MemoryDataExportRepository();
            var sm2   = new ShareManager(new RepositoryProvider(repo2));

            return(sm2.ImportSharedObject(shareDefinition).OfType <LoadMetadata>().Single());
        }
Esempio n. 5
0
        public void Create_ExternalCohortTable_Manually()
        {
            MemoryDataExportRepository repository = new MemoryDataExportRepository();
            var table = new ExternalCohortTable(repository, "My Cohort Database", DatabaseType.MicrosoftSQLServer);

            table.Database = "mydb";
            table.PrivateIdentifierField         = "chi";
            table.ReleaseIdentifierField         = "release";
            table.DefinitionTableForeignKeyField = "c_id";
            table.TableName           = "Cohorts";
            table.DefinitionTableName = "InventoryTable";
            table.Server = "superfastdatabaseserver\\sqlexpress";
            table.SaveToDatabase();

            var ex = Assert.Throws <Exception>(() => table.Check(new ThrowImmediatelyCheckNotifier()));

            Assert.AreEqual("Could not connect to Cohort database called 'My Cohort Database'", ex.Message);
        }
Esempio n. 6
0
        public TestActivateItems(UITests uiTests, MemoryDataExportRepository repo) : base(new RepositoryProvider(repo), new ToMemoryCheckNotifier())
        {
            _uiTests   = uiTests;
            Results    = new TestActivateItemsResults();
            RefreshBus = new RefreshBus();

            //don't load the comment store for every single test
            if (_commentStore == null)
            {
                _commentStore = new CommentStore();
                _commentStore.ReadComments(TestContext.CurrentContext.TestDirectory);
            }

            CommentStore = _commentStore;

            HistoryProvider = new HistoryProvider(RepositoryLocator);

            _problemProviders = new List <IProblemProvider>(new IProblemProvider[]
            {
                new CatalogueProblemProvider(),
                new DataExportProblemProvider()
            });
        }