示例#1
0
 public void NoMatchingFileHandlers_DoesNothing()
 {
     using (var bob = new RepositorySetup("bob"))
     {
         using(var cop = new CommitCop(bob.Repository , ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
         {
             bob.AddAndCheckinFile("test.abc", "hello");
         }
         bob.AssertLocalRevisionNumber(0);
     }
 }
示例#2
0
 public void HasFileHandlers_Validates_DoesNothing()
 {
     using (var bob = new RepositorySetup("bob"))
     {
         using (var cop = new CommitCop(bob.Repository, ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
         {
             bob.AddAndCheckinFile("test.chorusTest", "hello");
             // SUT
             Assert.IsNullOrEmpty(cop.ValidationResult);
         }
         bob.AssertLocalRevisionNumber(0);
     }
 }
示例#3
0
 public void SecondCheckin_Invalid_BacksOut()
 {
     using (var bob = new RepositorySetup("bob"))
     {
         bob.AddAndCheckinFile("test.chorusTest", "hello");
         bob.ChangeFile("test.chorusTest",ChorusTestFileHandler.GetInvalidContents());
         using (var cop = new CommitCop(bob.Repository, ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
         {
             Assert.IsFalse(string.IsNullOrEmpty(cop.ValidationResult));
             bob.Repository.Commit(false, "bad data");
         }
         Debug.WriteLine(bob.Repository.GetLog(-1));
         bob.AssertHeadCount(1);
         bob.AssertLocalRevisionNumber(2);
         bob.AssertFileContents("test.chorusTest", "hello");
     }
 }
示例#4
0
 public void InitialFileCommit_Invalid_BacksOut()
 {
     using(var bob = new RepositorySetup("bob"))
     {
         bob.AddAndCheckinFile("validfile.chorustest", "valid contents");
         bob.ChangeFile("test.chorusTest", ChorusTestFileHandler.GetInvalidContents());
         using(var cop = new CommitCop(bob.Repository, ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
         {
             bob.Repository.AddAndCheckinFile("test.chorusTest");
             Assert.That(cop.ValidationResult, Is.StringContaining("Failed"));
         }
         Debug.WriteLine(bob.Repository.GetLog(-1));
         bob.AssertHeadCount(1);
         bob.AssertLocalRevisionNumber(2);
         bob.AssertFileDoesNotExistInRepository("test.chorusTest");
         bob.AssertFileExistsInRepository("validfile.chorustest");
     }
 }
示例#5
0
 public void HasFileHandlers_ValidCommit_Validates_DoesNothing()
 {
     using(var bob = new RepositorySetup("bob"))
     {
         bob.AddAndCheckinFile("test.chorusTest", "hello");
         using(var cop = new CommitCop(bob.Repository, ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
         {
             bob.ChangeFile("test.chorusTest", "aloha");
             bob.AddAndCheckinFile("test2.chorusTest", "hi");
             Assert.IsNullOrEmpty(cop.ValidationResult);
         }
         bob.AssertHeadCount(1);
         bob.AssertLocalRevisionNumber(1);
         bob.AssertFileExistsInRepository("test2.chorusTest");
         bob.AssertFileContents("test.chorusTest", "aloha");
         bob.AssertFileContents("test2.chorusTest", "hi");
     }
 }
示例#6
0
        private void Commit(SyncOptions options)
        {
            ThrowIfCancelPending();
            _progress.WriteMessage("Storing changes in local repository...");

            _sychronizerAdjunct.PrepareForInitialCommit(_progress);

            // Must be done, before "AddAndCommitFiles" call.
            // It could be here, or first thing inside the 'using' for CommitCop.
            string tooLargeFilesMessage = LargeFileFilter.FilterFiles(Repository, _project, _handlers);

            if (!string.IsNullOrEmpty(tooLargeFilesMessage))
            {
                var msg = "We're sorry, but the Send/Receive system can't handle large files. The following files won't be stored or shared by this system until you can shrink them down below the maximum: " + Environment.NewLine;
                msg += tooLargeFilesMessage;
                _progress.WriteWarning(msg);
            }

            var commitCopValidationResult = "";

            using (var commitCop = new CommitCop(Repository, _handlers, _progress))
            {
                // NB: The commit must take place in order for CommitCop to work properly.
                // Ergo, don't even think of moving this after the commitCop.ValidationResult check.
                // Too bad I (RBR) already thought of it, and asked, and found out it ought not be moved. :-)
                AddAndCommitFiles(options.CheckinDescription);
                commitCopValidationResult = commitCop.ValidationResult;
            }
            if (string.IsNullOrEmpty(commitCopValidationResult))
            {
                return;
            }

            // Commit cop reported a validation failure, but deal with it here, rather than inside the 'using', as the rollback won't have happened,
            // until Dispose, and that is way too early for the "SimpleUpdate" call.
            _sychronizerAdjunct.SimpleUpdate(_progress, true);
            throw new ApplicationException(
                      "The changed data did not pass validation tests. Your project will be moved back to the last Send/Receive before this problem occurred, so that you can keep working.  Please notify whoever provides you with computer support. Error was: " +
                      commitCopValidationResult);
        }
示例#7
0
        private void Commit(SyncOptions options)
        {
            ThrowIfCancelPending();
            _progress.WriteMessage("Storing changes in local repository...");

            _sychronizerAdjunct.PrepareForInitialCommit(_progress);

            // Must be done, before "AddAndCommitFiles" call.
            // It could be here, or first thing inside the 'using' for CommitCop.
            string tooLargeFilesMessage = LargeFileFilter.FilterFiles(Repository, _project, _handlers);
            if (!string.IsNullOrEmpty(tooLargeFilesMessage))
            {
                var msg = "We're sorry, but the Send/Receive system can't handle large files. The following files won't be stored or shared by this system until you can shrink them down below the maximum: "+Environment.NewLine;
                msg+= tooLargeFilesMessage;
                _progress.WriteWarning(msg);
            }

            var commitCopValidationResult = "";
            using (var commitCop = new CommitCop(Repository, _handlers, _progress))
            {
                // NB: The commit must take place in order for CommitCop to work properly.
                // Ergo, don't even think of moving this after the commitCop.ValidationResult check.
                // Too bad I (RBR) already thought of it, and asked, and found out it ought not be moved. :-)
                AddAndCommitFiles(options.CheckinDescription);
                commitCopValidationResult = commitCop.ValidationResult;
            }
            if (string.IsNullOrEmpty(commitCopValidationResult))
                return;

            // Commit cop reported a validation failure, but deal with it here, rather than inside the 'using', as the rollback won't have happened,
            // until Dispose, and that is way too early for the "SimpleUpdate" call.
            _sychronizerAdjunct.SimpleUpdate(_progress, true);
            throw new ApplicationException(
                    "The changed data did not pass validation tests. Your project will be moved back to the last Send/Receive before this problem occurred, so that you can keep working.  Please notify whoever provides you with computer support. Error was: " +
                    commitCopValidationResult);
        }
示例#8
0
 public void VeryFirstCommit_Invalid_Throws()
 {
     string validationResult = null;
     Assert.Throws<ApplicationException>(() =>
     {
         using(var bob = new RepositorySetup("bob"))
         {
             bob.ChangeFile("test.chorusTest", ChorusTestFileHandler.GetInvalidContents());
             using(var cop = new CommitCop(bob.Repository, ChorusFileTypeHandlerCollection.CreateWithTestHandlerOnly(), bob.Progress))
             {
                 bob.Repository.AddAndCheckinFile("test.chorusTest");
                 // ReSharper disable once ReturnValueOfPureMethodIsNotUsed - SUT
                 validationResult = cop.ValidationResult;
             }
         }
     });
     Assert.That(validationResult, Is.StringContaining("Failed"));
 }