예제 #1
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);
            }
        }
예제 #2
0
        public void TransferMongoToLcmAction_NoChangedData_DateModifiedUnchanged()
        {
            // Setup
            TestEnvironment.CopyFwProjectTo(testProjectCode, _lDSettings.WebWorkDirectory);
            _lfProject.IsInitialClone = true;
            _transferLcmToMongo.Run(_lfProject);

            // Exercise
            var transferMongoToLcm = new TransferMongoToLcmAction(_env.Settings, _env.Logger,
                                                                  _mongoConnection, _recordFactory, _counts);

            transferMongoToLcm.Run(_lfProject);

            // Verify
            var lfcache    = _lfProject.FieldWorksProject.Cache;
            var lfLcmEntry = lfcache.ServiceLocator.GetObject(_testEntryGuid) as ILexEntry;

            Assert.That(lfLcmEntry.DateModified.ToUniversalTime(),
                        Is.EqualTo(DateTime.Parse("2016-02-25 03:51:29.404")));
        }