public void Success_NoNewChangesFromOthersAndUs()
        {
            // Setup
            TestEnvironment.CopyFwProjectTo(TestLangProj, _lDSettings.WebWorkDirectory);
            TestEnvironment.CopyFwProjectTo(TestLangProj, _env.Settings.WebWorkDirectory);
            LanguageDepotMock.Server.Start();
            var ldDirectory = Path.Combine(_lDSettings.WebWorkDirectory, TestLangProj);
            var oldHashOfLd = MercurialTestHelper.GetRevisionOfTip(ldDirectory);

            // Execute
            _synchronizeAction.Run(_lfProject);

            // Verify
            Assert.That(MercurialTestHelper.GetRevisionOfTip(ldDirectory), Is.EqualTo(oldHashOfLd));
            Assert.That(MercurialTestHelper.GetRevisionOfWorkingSet(_lfProject.ProjectDir),
                        Is.EqualTo(oldHashOfLd));
            Assert.That(_env.Logger.GetErrors(), Is.Null.Or.Empty);
            Assert.That(_env.Logger.GetMessages(), Does.Contain("No changes from others"));
            Assert.That(_lfProject.State.SRState, Is.EqualTo(ProcessingState.SendReceiveStates.SYNCING));
        }
        public void Success_ChangesFromOthersNoChangesFromUs()
        {
            // Setup
            var ldDirectory = CopyModifiedProjectAsTestLangProj(_lDSettings.WebWorkDirectory);

            TestEnvironment.CopyFwProjectTo(TestLangProj, _env.Settings.WebWorkDirectory);
            LanguageDepotMock.Server.Start();
            var oldHashOfLd = MercurialTestHelper.GetRevisionOfTip(ldDirectory);

            // Execute
            _synchronizeAction.Run(_lfProject);

            // Verify
            Assert.That(MercurialTestHelper.GetRevisionOfWorkingSet(_lfProject.ProjectDir),
                        Is.EqualTo(MercurialTestHelper.GetRevisionOfTip(ldDirectory)),
                        "Our repo doesn't have the changes from LanguageDepot");
            Assert.That(MercurialTestHelper.GetRevisionOfTip(ldDirectory), Is.EqualTo(oldHashOfLd));
            Assert.That(_env.Logger.GetErrors(), Is.Null.Or.Empty);
            Assert.That(_env.Logger.GetMessages(), Does.Contain("Received changes from others"));
            Assert.That(_lfProject.State.SRState, Is.EqualTo(ProcessingState.SendReceiveStates.SYNCING));
        }
        public void Success_NewBranchFormat_LfMerge68()
        {
            // Setup
            var ldDirectory = CopyModifiedProjectAsTestLangProj(_lDSettings.WebWorkDirectory);

            TestEnvironment.CopyFwProjectTo(TestLangProj, _env.Settings.WebWorkDirectory);
            TestEnvironment.WriteTextFile(Path.Combine(_env.Settings.WebWorkDirectory, TestLangProj, "FLExProject.ModelVersion"), "{\"modelversion\": 7000068}");
            LanguageDepotMock.Server.Start();
            var oldHashOfLd = MercurialTestHelper.GetRevisionOfTip(ldDirectory);

            // Execute
            _synchronizeAction.Run(_lfProject);

            // Verify
            Assert.That(MercurialTestHelper.GetRevisionOfWorkingSet(_lfProject.ProjectDir),
                        Is.EqualTo(MercurialTestHelper.GetRevisionOfTip(ldDirectory)),
                        "Our repo doesn't have the changes from LanguageDepot");
            Assert.That(MercurialTestHelper.GetRevisionOfTip(ldDirectory), Is.EqualTo(oldHashOfLd));
            Assert.That(_env.Logger.GetErrors(), Is.Null.Or.Empty);
            Assert.That(_env.Logger.GetMessages(), Does.Contain("Received changes from others"));
        }
Example #4
0
        public void Success_ChangesFromUsNoChangesFromOthers()
        {
            // Setup
            CopyModifiedProjectAsTestLangProj(_env.Settings.WebWorkDirectory);
            TestEnvironment.CopyFwProjectTo(TestLangProj, _lDSettings.WebWorkDirectory);
            LanguageDepotMock.Server.Start();
            var oldHashOfUs = MercurialTestHelper.GetRevisionOfWorkingSet(_lfProject.ProjectDir);

            // Execute
            _synchronizeAction.Run(_lfProject);

            // Verify
            Assert.That(MercurialTestHelper.GetRevisionOfWorkingSet(_lfProject.ProjectDir),
                        Is.EqualTo(oldHashOfUs));
            Assert.That(MercurialTestHelper.GetRevisionOfTip(
                            Path.Combine(_lDSettings.WebWorkDirectory, TestLangProj)),
                        Is.EqualTo(oldHashOfUs), "LanguageDepot doesn't have our changes");
            Assert.That(_env.Logger.GetErrors(), Is.Null.Or.Empty);
            Assert.That(_env.Logger.GetMessages(), Is.StringContaining("No changes from others"));
            Assert.That(_lfProject.State.SRState, Is.EqualTo(ProcessingState.SendReceiveStates.SYNCING));
        }
        public void Error_InvalidUtf8InXml()
        {
            // Setup
            TestEnvironment.CopyFwProjectTo(TestLangProj, _lDSettings.WebWorkDirectory);
            TestEnvironment.CopyFwProjectTo(TestLangProj, _env.Settings.WebWorkDirectory);
            LanguageDepotMock.Server.Start();
            var ldDirectory = Path.Combine(_lDSettings.WebWorkDirectory, TestLangProj);
            var oldHashOfLd = MercurialTestHelper.GetRevisionOfTip(ldDirectory);
            var fwdataPath  = Path.Combine(_env.Settings.WebWorkDirectory, TestLangProj, TestLangProj + ".fwdata");

            TestEnvironment.OverwriteBytesInFile(fwdataPath, new byte[] { 0xc0, 0xc1 }, 25);            // 0xC0 and 0xC1 are always invalid byte values in UTF-8

            // Execute
            _synchronizeAction.Run(_lfProject);

            // Verify
            string errors = _env.Logger.GetErrors();

            Assert.That(errors, Does.Contain("System.Xml.XmlException"));
            // Stack trace should also have been logged
            Assert.That(errors, Does.Contain("\n  at Chorus.sync.Synchronizer.SyncNow (Chorus.sync.SyncOptions options)"));
            Assert.That(_lfProject.State.SRState, Is.EqualTo(ProcessingState.SendReceiveStates.SYNCING));
        }
        public void Error_WrongXmlEncoding()
        {
            // Setup
            TestEnvironment.CopyFwProjectTo(TestLangProj, _lDSettings.WebWorkDirectory);
            TestEnvironment.CopyFwProjectTo(TestLangProj, _env.Settings.WebWorkDirectory);
            LanguageDepotMock.Server.Start();
            var ldDirectory = Path.Combine(_lDSettings.WebWorkDirectory, TestLangProj);
            var oldHashOfLd = MercurialTestHelper.GetRevisionOfTip(ldDirectory);
            var fwdataPath  = Path.Combine(_env.Settings.WebWorkDirectory, TestLangProj, TestLangProj + ".fwdata");

            TestEnvironment.ChangeFileEncoding(fwdataPath, System.Text.Encoding.UTF8, System.Text.Encoding.UTF32);
            // Note that the XML file will still claim the encoding is UTF-8!

            // Execute
            _synchronizeAction.Run(_lfProject);

            // Verify
            string errors = _env.Logger.GetErrors();

            Assert.That(errors, Does.Contain("System.Xml.XmlException: '.', hexadecimal value 0x00, is an invalid character."));
            // Stack trace should also have been logged
            Assert.That(errors, Does.Contain("\n  at Chorus.sync.Synchronizer.SyncNow (Chorus.sync.SyncOptions options)"));
            Assert.That(_lfProject.State.SRState, Is.EqualTo(ProcessingState.SendReceiveStates.SYNCING));
        }