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 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);
        }
Beispiel #3
0
        public void EnsureProjectIsShared()
        {
            var liftProject = CreateNewbieProject();

            Directory.CreateDirectory(Path.Combine(_pathToProject, ".hg"));
            Assert.IsTrue(LiftProjectServices.ProjectIsShared(liftProject));
        }
        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);
        }
        /// <summary>
        /// Do the Send/Receive for the given language project name.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <param name="projectName"/> is null or an empty string.
        /// </exception>
        public void DoSendReceiveForLanguageProject(Form parent, string projectName)
        {
            if (string.IsNullOrEmpty(projectName))
            {
                throw new ArgumentNullException("projectName");
            }

            Liftproject = _languageProjectGuid == Guid.Empty
                                ? new LiftProject(projectName) // Try to support backwards compatibility.
                                : new LiftProject(projectName, _languageProjectGuid);

            try
            {
                if (LiftProjectServices.ProjectIsShared(Liftproject))
                {
                    InstallExistingSystemControl();
                }
                else
                {
                    InstallNewSystem();
                }
                _liftBridgeView.Show(parent, string.Format(Resources.kTitle, Liftproject.LiftProjectName));
            }
            finally
            {
                _liftBridgeView.Dispose();
            }
        }
Beispiel #6
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;
        }
Beispiel #9
0
        public void EnsureProjectIsNotShared()
        {
            var liftProject = CreateNewbieProject();

            Assert.IsFalse(LiftProjectServices.ProjectIsShared(liftProject));
        }
        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();
        }