コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: LcmTestBase.cs プロジェクト: sillsdev/LfMerge
        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);
            }
        }
コード例 #3
0
        public void Setup()
        {
            _env         = new TestEnvironment();
            _projectCode = TestContext.CurrentContext.Test.Name.ToLowerInvariant();
            var _projectDir = Path.Combine(_env.Settings.WebWorkDirectory, _projectCode);

            Directory.CreateDirectory(_projectDir);
            // Making a stub file so Chorus model.TargetLocationIsUnused will be false
            File.Create(Path.Combine(_projectDir, "stub"));
            _mongoProjectRecordFactory = MainClass.Container.Resolve <MongoProjectRecordFactory>() as MongoProjectRecordFactoryDouble;
            _mongoConnection           = _mongoProjectRecordFactory.Connection as MongoConnectionDouble;
            if (_mongoConnection == null)
            {
                throw new AssertionException("EnsureClone action tests need a mock MongoConnection that stores data in order to work.");
            }
        }
コード例 #4
0
        public TestEnvironment(bool registerSettingsModelDouble = true,
			bool registerProcessingStateDouble = true,
			bool resetLfProjectsDuringCleanup = true,
			TemporaryFolder languageForgeServerFolder = null,
			bool registerLfProxyMock = true)
        {
            _resetLfProjectsDuringCleanup = resetLfProjectsDuringCleanup;
            _languageForgeServerFolder = languageForgeServerFolder ?? new TemporaryFolder(TestName + Path.GetRandomFileName());
            Environment.SetEnvironmentVariable("FW_CommonAppData", _languageForgeServerFolder.Path);
            MainClass.Container = RegisterTypes(registerSettingsModelDouble,
                registerProcessingStateDouble, _languageForgeServerFolder.Path,
                registerLfProxyMock).Build();
            Settings = MainClass.Container.Resolve<LfMergeSettingsIni>();
            MainClass.Logger = MainClass.Container.Resolve<ILogger>();
            Directory.CreateDirectory(Settings.ProjectsDirectory);
            Directory.CreateDirectory(Settings.TemplateDirectory);
            Directory.CreateDirectory(Settings.StateDirectory);
            _mongoConnection = MainClass.Container.Resolve<IMongoConnection>() as MongoConnectionDouble;
        }
コード例 #5
0
ファイル: FdoTestBase.cs プロジェクト: ermshiperete/LfMerge
        public void Setup()
        {
            _env = new TestEnvironment(resetLfProjectsDuringCleanup: false);
            _conn = MainClass.Container.Resolve<IMongoConnection>() as MongoConnectionDouble;
            if (_conn == null)
                throw new AssertionException("FDO 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->Fdo roundtrip tests need a mock MongoProjectRecordFactory in order to work.");

            _lfProj = FdoTestFixture.lfProj;
            _cache = _lfProj.FieldWorksProject.Cache;
            _wsEn = _cache.WritingSystemFactory.GetWsFromStr("en");
            _undoHelper = new UndoableUnitOfWorkHelper(_cache.ActionHandlerAccessor, "undo", "redo");
            _undoHelper.RollBack = true;

            sutMongoToFdo = new TransferMongoToFdoAction(
                _env.Settings,
                _env.Logger,
                _conn,
                _recordFactory
            );

            sutFdoToMongo = new TransferFdoToMongoAction(
                _env.Settings,
                _env.Logger,
                _conn
            );

            var convertCustomField = new ConvertFdoToMongoCustomField(_cache, _env.Logger);
            _listConverters = new Dictionary<string, ConvertFdoToMongoOptionList>();
            foreach (KeyValuePair<string, ICmPossibilityList> pair in convertCustomField.GetCustomFieldParentLists())
            {
                string listCode = pair.Key;
                ICmPossibilityList parentList = pair.Value;
                _listConverters[listCode] = ConvertOptionListFromFdo(_lfProj, listCode, parentList);
            }
        }
コード例 #6
0
        public void Setup()
        {
            _env = new TestEnvironment();
            _env.Settings.CommitWhenDone = true;
            _lfProject = LanguageForgeProject.Create(_env.Settings, 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");
            _lDSettings = new LfMergeSettingsDouble(_languageDepotFolder.Path);
            Directory.CreateDirectory(_lDSettings.WebWorkDirectory);
            LDProjectFolderPath = 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);
        }