Esempio n. 1
0
 public EnsureCloneActionDoubleMockErrorCondition(LfMergeSettings settings, ILogger logger,
                                                  MongoProjectRecordFactory projectRecordFactory, IMongoConnection connection,
                                                  string cloneResult) :
     base(settings, logger, projectRecordFactory, connection)
 {
     _cloneResult = cloneResult;
 }
        public void Setup()
        {
            _env = new TestEnvironment();
            _env.Settings.CommitWhenDone = true;
            _counts    = MainClass.Container.Resolve <EntryCounts>();
            _lfProject = LanguageForgeProject.Create(testProjectCode);
            TestEnvironment.CopyFwProjectTo(testProjectCode, _env.Settings.WebWorkDirectory);

            // Guids are named for the diffs for the modified test project
            _testEntryGuid        = Guid.Parse(testEntryGuidStr);
            _testCreatedEntryGuid = Guid.Parse(testCreatedEntryGuidStr);
            _testDeletedEntryGuid = Guid.Parse(testDeletedEntryGuidStr);

            _languageDepotFolder = new TemporaryFolder("SyncTestLD" + Path.GetRandomFileName());
            _lDSettings          = new LfMergeSettingsDouble(_languageDepotFolder.Path);
            Directory.CreateDirectory(_lDSettings.WebWorkDirectory);
            LanguageDepotMock.ProjectFolderPath = Path.Combine(_lDSettings.WebWorkDirectory, testProjectCode);

            _mongoConnection = MainClass.Container.Resolve <IMongoConnection>() as MongoConnectionDouble;
            if (_mongoConnection == null)
            {
                throw new AssertionException("Sync tests need a mock MongoConnection that stores data in order to work.");
            }
            _recordFactory = MainClass.Container.Resolve <MongoProjectRecordFactory>() as MongoProjectRecordFactoryDouble;
            if (_recordFactory == null)
            {
                throw new AssertionException("Sync tests need a mock MongoProjectRecordFactory in order to work.");
            }

            _transferFdoToMongo = new TransferFdoToMongoAction(_env.Settings, _env.Logger, _mongoConnection, _recordFactory);
        }
Esempio n. 3
0
 public EnsureCloneActionDouble(LfMergeSettings settings, ILogger logger,
                                MongoProjectRecordFactory projectRecordFactory, IMongoConnection connection,
                                bool projectExists = true, bool throwAuthorizationException = true) :
     base(settings, logger, projectRecordFactory, connection)
 {
     _projectExists = projectExists;
     _throwAuthorizationException = throwAuthorizationException;
 }
Esempio n. 4
0
 public ConvertLcmToMongoComments(IMongoConnection conn, ILfProject proj, ILogger logger, IProgress progress, MongoProjectRecordFactory factory)
 {
     _conn     = conn;
     _project  = proj;
     _servLoc  = proj.FieldWorksProject.ServiceLocator;
     _logger   = logger;
     _progress = progress;
     _factory  = factory;
 }
Esempio n. 5
0
        //private ConvertFdoToMongoOptionList _convertAnthroCodesOptionList;

        public ConvertFdoToMongoLexicon(ILfProject lfProject, ILogger logger, IMongoConnection connection, IProgress progress, MongoProjectRecordFactory projectRecordFactory)
        {
            LfProject            = lfProject;
            Logger               = logger;
            Connection           = connection;
            Progress             = progress;
            ProjectRecordFactory = projectRecordFactory;

            FwProject      = LfProject.FieldWorksProject;
            Cache          = FwProject.Cache;
            ServiceLocator = FwProject.ServiceLocator;
            _wsEn          = ServiceLocator.WritingSystemFactory.GetWsFromStr("en");

            // Reconcile writing systems from FDO and Mongo
            Dictionary <string, LfInputSystemRecord> lfWsList = FdoWsToLfWs();

                        #if FW8_COMPAT
            List <string> VernacularWss    = ServiceLocator.LanguageProject.CurrentVernacularWritingSystems.Select(ws => ws.Id).ToList();
            List <string> AnalysisWss      = ServiceLocator.LanguageProject.CurrentAnalysisWritingSystems.Select(ws => ws.Id).ToList();
            List <string> PronunciationWss = ServiceLocator.LanguageProject.CurrentPronunciationWritingSystems.Select(ws => ws.Id).ToList();
                        #else
            List <string> VernacularWss    = ServiceLocator.LanguageProject.CurrentVernacularWritingSystems.Select(ws => ws.LanguageTag).ToList();
            List <string> AnalysisWss      = ServiceLocator.LanguageProject.CurrentAnalysisWritingSystems.Select(ws => ws.LanguageTag).ToList();
            List <string> PronunciationWss = ServiceLocator.LanguageProject.CurrentPronunciationWritingSystems.Select(ws => ws.LanguageTag).ToList();
                        #endif
            Connection.SetInputSystems(LfProject, lfWsList, VernacularWss, AnalysisWss, PronunciationWss);

            ListConverters = new Dictionary <string, ConvertFdoToMongoOptionList>();
            ListConverters[GrammarListCode]        = ConvertOptionListFromFdo(LfProject, GrammarListCode, ServiceLocator.LanguageProject.PartsOfSpeechOA);
            ListConverters[SemDomListCode]         = ConvertOptionListFromFdo(LfProject, SemDomListCode, ServiceLocator.LanguageProject.SemanticDomainListOA, updateMongoList: false);
            ListConverters[AcademicDomainListCode] = ConvertOptionListFromFdo(LfProject, AcademicDomainListCode, ServiceLocator.LanguageProject.LexDbOA.DomainTypesOA);
            ListConverters[LocationListCode]       = ConvertOptionListFromFdo(LfProject, LocationListCode, ServiceLocator.LanguageProject.LocationsOA);
            ListConverters[UsageTypeListCode]      = ConvertOptionListFromFdo(LfProject, UsageTypeListCode, ServiceLocator.LanguageProject.LexDbOA.UsageTypesOA);
            ListConverters[SenseTypeListCode]      = ConvertOptionListFromFdo(LfProject, SenseTypeListCode, ServiceLocator.LanguageProject.LexDbOA.SenseTypesOA);
            ListConverters[AnthroCodeListCode]     = ConvertOptionListFromFdo(LfProject, AnthroCodeListCode, ServiceLocator.LanguageProject.AnthroListOA);
            ListConverters[StatusListCode]         = ConvertOptionListFromFdo(LfProject, StatusListCode, ServiceLocator.LanguageProject.StatusOA);

            _convertCustomField = new ConvertFdoToMongoCustomField(Cache, ServiceLocator, logger);
            foreach (KeyValuePair <string, ICmPossibilityList> pair in _convertCustomField.GetCustomFieldParentLists())
            {
                string             listCode   = pair.Key;
                ICmPossibilityList parentList = pair.Value;
                if (!ListConverters.ContainsKey(listCode))
                {
                    ListConverters[listCode] = ConvertOptionListFromFdo(LfProject, listCode, parentList);
                }
            }
        }
Esempio n. 6
0
        public void Setup()
        {
            _env    = new TestEnvironment(resetLfProjectsDuringCleanup: false);
            _conn   = MainClass.Container.Resolve <IMongoConnection>() as MongoConnectionDouble;
            _counts = MainClass.Container.Resolve <EntryCounts>();
            if (_conn == null)
            {
                throw new AssertionException("LCM tests need a mock MongoConnection that stores data in order to work.");
            }
            _recordFactory = MainClass.Container.Resolve <MongoProjectRecordFactory>() as MongoProjectRecordFactoryDouble;
            if (_recordFactory == null)
            {
                throw new AssertionException("Mongo->Lcm roundtrip tests need a mock MongoProjectRecordFactory in order to work.");
            }

            _lfProj = LcmTestFixture.lfProj;
            _cache  = _lfProj.FieldWorksProject.Cache;
            Assert.That(_cache, Is.Not.Null);
            _servLoc             = new FwServiceLocatorCache(_cache.ServiceLocator);
            _wsEn                = _cache.WritingSystemFactory.GetWsFromStr("en");
            _undoHelper          = new UndoableUnitOfWorkHelper(_cache.ActionHandlerAccessor, "undo", "redo");
            _undoHelper.RollBack = true;

            SutMongoToLcm = new TransferMongoToLcmAction(
                _env.Settings,
                _env.Logger,
                _conn,
                _recordFactory,
                _counts
                );

            SutLcmToMongo = new TransferLcmToMongoAction(
                _env.Settings,
                _env.Logger,
                _conn,
                _recordFactory
                );

            var convertCustomField = new ConvertLcmToMongoCustomField(_cache, _servLoc, _env.Logger);

            _listConverters = new Dictionary <string, ConvertLcmToMongoOptionList>();
            foreach (KeyValuePair <string, ICmPossibilityList> pair in convertCustomField.GetCustomFieldParentLists())
            {
                string             listCode   = pair.Key;
                ICmPossibilityList parentList = pair.Value;
                _listConverters[listCode] = ConvertOptionListFromLcm(_lfProj, listCode, parentList);
            }
        }
Esempio n. 7
0
 public TransferMongoToLcmAction(LfMergeSettings settings, ILogger logger, IMongoConnection conn, MongoProjectRecordFactory factory, EntryCounts entryCounts) : base(settings, logger)
 {
     EntryCounts           = entryCounts;
     _connection           = conn;
     _projectRecordFactory = factory;
 }
Esempio n. 8
0
 public TransferFdoToMongoAction(LfMergeSettings settings, ILogger logger, IMongoConnection conn, MongoProjectRecordFactory projectRecordFactory) : base(settings, logger)
 {
     _connection           = conn;
     _projectRecordFactory = projectRecordFactory;
 }
Esempio n. 9
0
 public EnsureCloneAction(LfMergeSettings settings, ILogger logger, MongoProjectRecordFactory projectRecordFactory, IMongoConnection connection) : base(settings, logger)
 {
     _projectRecordFactory = projectRecordFactory;
     _connection           = connection;
 }
Esempio n. 10
0
 public EnsureCloneActionDoubleMockingInitialTransfer(LfMergeSettings settings, ILogger logger,
                                                      MongoProjectRecordFactory projectRecordFactory, IMongoConnection connection, bool projectExists = true) :
     base(settings, logger, projectRecordFactory, connection, projectExists)
 {
     InitialCloneWasRun = false;
 }
Esempio n. 11
0
 public EnsureCloneActionWithoutMongo(LfMergeSettings settings, ILogger logger, MongoProjectRecordFactory factory, IMongoConnection connection)
     : base(settings, logger, factory, connection)
 {
 }