public void EnsureControllerManagesMainLiftBridgeViewUsingExtantSystemWithNoChangesFromAfar()
        {
            var mockedClient = new MockedLiftBridgeClient(_liftBridgeController);

            Assert.IsFalse(mockedClient.HandledBasicLexiconImport);
            Assert.IsFalse(mockedClient.HandledImportLexicon);
            Assert.IsFalse(mockedClient.HandledExportLexicon);

            var liftProject = new LiftProject("DProject");

            _pathToProject = LiftProjectServices.PathToProject(liftProject);
            Directory.CreateDirectory(_pathToProject);
            Directory.CreateDirectory(Path.Combine(_pathToProject, ".hg"));
            var projPath     = LiftProjectServices.PathToProject(liftProject);
            var liftPathname = Path.Combine(projPath, "DProject.lift");

            File.WriteAllText(liftPathname, "");

            _liftBridgeController.DoSendReceiveForLanguageProject(_parentForm, "DProject");

            _mockedExistingSystem.SimulateSendReceiveWithNoChangesFromAfar();

            // Should be the existing system view by now.
            Assert.AreSame(_mockedExistingSystem, _mockedLiftBridgeView.ActiveView);
            Assert.IsTrue(_mockedExistingSystem.ExportLexiconIsWiredUp);
            Assert.IsTrue(_mockedExistingSystem.ImportLexiconIsWiredUp);

            Assert.IsFalse(mockedClient.HandledBasicLexiconImport);
            Assert.IsFalse(mockedClient.HandledImportLexicon);
            Assert.IsTrue(mockedClient.HandledExportLexicon);
        }
        public void EnsureControllerManagesMainLiftBridgeViewStartingWithStartupViewAndEndingWithExistingView()
        {
            var mockedClient = new MockedLiftBridgeClient(_liftBridgeController);

            Assert.IsFalse(mockedClient.HandledBasicLexiconImport);
            Assert.IsFalse(mockedClient.HandledImportLexicon);
            Assert.IsFalse(mockedClient.HandledExportLexicon);

            _liftBridgeController.DoSendReceiveForLanguageProject(_parentForm, "AProject");
            var lp = _liftBridgeController.Liftproject;

            _pathToProject = LiftProjectServices.PathToProject(lp);
            Assert.IsNotNull(_mockedLiftBridgeView.MainForm);
            Assert.AreSame(_parentForm, _mockedLiftBridgeView.MainForm);
            Assert.AreEqual("LIFT Bridge: AProject", _mockedLiftBridgeView.Title);
            Assert.AreSame(_mockedStartupNewView, _mockedLiftBridgeView.ActiveView);

            var projPath     = LiftProjectServices.PathToProject(lp);
            var liftPathname = Path.Combine(projPath, "AProject.lift");

            Assert.IsFalse(File.Exists(liftPathname));

            _mockedStartupNewView.RaiseStartupOnNewShare();
            Assert.IsTrue(File.Exists(liftPathname));
            // Should be the existing system view by now.
            Assert.AreSame(_mockedExistingSystem, _mockedLiftBridgeView.ActiveView);
            Assert.IsTrue(_mockedExistingSystem.ExportLexiconIsWiredUp);
            Assert.IsTrue(_mockedExistingSystem.ImportLexiconIsWiredUp);

            Assert.IsFalse(mockedClient.HandledBasicLexiconImport);
            Assert.IsFalse(mockedClient.HandledImportLexicon);
            Assert.IsFalse(mockedClient.HandledExportLexicon);
        }
        public void EnsureControllerManagesMainLiftBridgeViewUsingExtantSystem()
        {
            var mockedClient = new MockedLiftBridgeClient(_liftBridgeController);

            Assert.IsFalse(mockedClient.HandledBasicLexiconImport);
            Assert.IsFalse(mockedClient.HandledImportLexicon);
            Assert.IsFalse(mockedClient.HandledExportLexicon);

            _liftBridgeController.DoSendReceiveForLanguageProject(_parentForm, "BProject");
            var lp = _liftBridgeController.Liftproject;

            _pathToProject = LiftProjectServices.PathToProject(lp);
            var projPath     = LiftProjectServices.PathToProject(lp);
            var liftPathname = Path.Combine(projPath, "BProject.lift");

            _mockedStartupNewView.RaiseStartupOnExtantShare();
            File.WriteAllText(liftPathname, "");
            Assert.IsTrue(File.Exists(liftPathname));
            // Should be the existing system view by now.
            Assert.AreSame(_mockedExistingSystem, _mockedLiftBridgeView.ActiveView);
            Assert.IsTrue(_mockedExistingSystem.ExportLexiconIsWiredUp);
            Assert.IsTrue(_mockedExistingSystem.ImportLexiconIsWiredUp);

            Assert.IsTrue(mockedClient.HandledBasicLexiconImport);
            Assert.IsFalse(mockedClient.HandledImportLexicon);
            Assert.IsFalse(mockedClient.HandledExportLexicon);
        }
Пример #4
0
        private LiftProject CreateNewbieProject(string projectName)
        {
            var liftProject = new LiftProject(projectName);

            _pathToProject = LiftProjectServices.PathToProject(liftProject);
            Directory.CreateDirectory(_pathToProject);
            return(liftProject);
        }
        public void EnsureControllerhasProject()
        {
            _liftBridgeController.DoSendReceiveForLanguageProject(_parentForm, "SomeProject");
            var lp = _liftBridgeController.Liftproject;

            _pathToProject = LiftProjectServices.PathToProject(lp);
            Assert.IsNotNull(lp);
            Assert.AreEqual("SomeProject", lp.LiftProjectName);
        }
        private void InstallExistingSystemControl()
        {
            if (_startupNewView != null)
            {
                _startupNewView.Startup -= Startup;
            }

            var chorusSystem = new ChorusSystem(LiftProjectServices.PathToProject(Liftproject), Environment.UserName);

            LiftFolder.AddLiftFileInfoToFolderConfiguration(chorusSystem.ProjectFolderConfiguration);
            _existingSystemView.SetSystem(chorusSystem, Liftproject);
            _liftBridgeView.ActivateView(_existingSystemView);
            _existingSystemView.ImportLexicon      += OnImportLexicon;
            _existingSystemView.ExportLexicon      += OnExportLexicon;
            _existingSystemView.BasicImportLexicon += OnBasicImport;
        }
        void Startup(object sender, StartupNewEventArgs e)
        {
            switch (e.SystemType)
            {
            default:
                throw new InvalidOperationException("Unrecognized type of shared system.");

            case SharedSystemType.New:
                // Create new repo with empty LIFT file.
                var newRepoPath     = LiftProjectServices.PathToProject(Liftproject);                     // DirectoryUtilities.GetUniqueFolderPath(LiftProjectServices.PathToProject(Liftproject));
                var newLiftPathname = Path.Combine(
                    newRepoPath,
                    Liftproject.LiftProjectName + ".lift");
                File.WriteAllText(newLiftPathname, Resources.kEmptyLiftFileXml);
                HgRepository.CreateRepositoryInExistingDir(newRepoPath, new NullProgress());
                var newRepo = new HgRepository(newRepoPath, new NullProgress());
                newRepo.AddAndCheckinFile(newLiftPathname);
                Liftproject.RepositoryIdentifier = newRepo.Identifier;
                break;

            case SharedSystemType.Extant:
                var result = _getSharedProject.GetSharedProjectUsing(MainForm, e.ExtantRepoSource, ProjectFilter, LiftProjectServices.BasePath, Liftproject.LiftProjectName);
                switch (result.CloneStatus)
                {
                //case CloneResult.OkToCreate: Not going to be returned.
                //  break;
                case CloneStatus.NotCreated:
                    // Clone not made for some reason.
                    MessageBox.Show(MainForm, Resources.kDidNotCloneSystem, Resources.kLiftSetUp, MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                    _liftBridgeView.Close();
                    return;

                case CloneStatus.Cancelled:
                    MessageBox.Show(MainForm, Resources.kUserCancelledCloneOperation, Resources.kSharingAttempCancelled, MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    _liftBridgeView.Close();
                    return;

                case CloneStatus.Created:
                    // Proceed
                    var clonedRepo = new HgRepository(result.ActualLocation, new NullProgress());
                    Liftproject.RepositoryIdentifier = clonedRepo.Identifier;
                    break;
                }

                if (BasicLexiconImport != null)
                {
                    var eventArgs = new LiftBridgeEventArgs(Liftproject.LiftPathname);
                    BasicLexiconImport(this, eventArgs);
                    if (eventArgs.Cancel)
                    {
                        // Event handler could not complete the basic import.
                        ImportFailureServices.RegisterBasicImportFailure((_liftBridgeView as Form), Liftproject);
                        _liftBridgeView.Close();
                        return;
                    }
                }
                break;
            }

            InstallExistingSystemControl();
        }