Ejemplo n.º 1
0
        public void Lock_BasicLock()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Empty);
            string WcPath = sbox.Wc;

            string filepath = Path.Combine(WcPath, "Form.cs");

            TouchFile(filepath);
            Client.Add(filepath);
            Client.Commit(filepath);

            Client.Status(filepath, delegate(object sender, SvnStatusEventArgs e)
            {
                Assert.That(e.LocalLock, Is.Null);
            });

            string      comment = "Moo\nMa";
            bool        gotIn   = false;
            SvnLockArgs la      = new SvnLockArgs();

            la.Comment = comment;
            la.Notify +=
                delegate(object sender, SvnNotifyEventArgs e)
            {
                Assert.That(e.Action, Is.EqualTo(SvnNotifyAction.LockLocked));
                gotIn = true;
            };
            Client.Lock(new string[] { filepath }, la);
            Assert.That(gotIn);

            gotIn   = false;
            comment = comment.Replace("\n", "\r\n");

            Client.Status(filepath, delegate(object sender, SvnStatusEventArgs e)
            {
                Assert.That(e.LocalLock, Is.Not.Null);
                Assert.That(e.LocalLock.Owner, Is.EqualTo(Environment.UserName));
                Assert.That(e.LocalLock.Token, Is.Not.Null);
                Assert.That(e.LocalLock.Comment, Is.EqualTo(comment));
                Assert.That(e.LocalLock.CreationTime.ToLocalTime(), Is.LessThanOrEqualTo(DateTime.Now).And.GreaterThan(DateTime.Now - new TimeSpan(0, 0, 20)));
                gotIn = true;
            });

            Assert.That(gotIn);
        }
Ejemplo n.º 2
0
        public void InfoTest()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string          dir = sbox.Wc;
            SvnUpdateResult r;

            Client.CheckOut(CollabReposUri, dir, out r);

            int i = 0;

            Assert.That(Client.Info(dir,
                                    delegate(object sender, SvnInfoEventArgs e)
            {
                i++;
                Assert.That(e.Revision, Is.EqualTo(r.Revision));
                Assert.That(e.LastChangeRevision, Is.EqualTo(r.Revision));
            }), Is.True);


            Assert.That(i, Is.EqualTo(1));

            i = 0;
            SvnInfoArgs aa = new SvnInfoArgs();

            aa.Depth = SvnDepth.Children;

            Assert.That(Client.Info(dir, aa,
                                    delegate(object sender, SvnInfoEventArgs e)
            {
                i++;
                Assert.That(e.Revision, Is.EqualTo(r.Revision));
                Assert.That(e.LastChangeRevision, Is.LessThanOrEqualTo(r.Revision));
            }), Is.True);

            Assert.That(i, Is.EqualTo(4)); // trunk branches tags
        }
Ejemplo n.º 3
0
        public void TestInfo()
        {
            SvnSandBox sbox     = new SvnSandBox(this);
            Uri        reposUri = sbox.CreateRepository(SandBoxRepository.Empty);
            Uri        WcUri    = reposUri;
            string     wc       = sbox.Wc;

            using (SvnClient client = NewSvnClient(true, false))
            {
                client.CheckOut(reposUri, wc);

                string file = Path.Combine(wc, "InfoFile");
                TouchFile(file);
                client.Add(file);

                bool visited = false;
                client.Info(file, delegate(object sender, SvnInfoEventArgs e)
                {
                    Assert.That(e.ChangeList, Is.Null);
                    Assert.That(e.Checksum, Is.Null);
                    Assert.That(e.ConflictNew, Is.Null);
                    Assert.That(e.ConflictOld, Is.Null);
                    Assert.That(e.ConflictWork, Is.Null);
                    Assert.That(e.ContentTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.CopyFromRevision, Is.EqualTo(-1L));
                    Assert.That(e.CopyFromUri, Is.Null);
                    Assert.That(e.Depth, Is.EqualTo(SvnDepth.Unknown));
                    Assert.That(e.FullPath, Is.EqualTo(file));
                    Assert.That(e.HasLocalInfo, Is.True);
                    Assert.That(e.LastChangeAuthor, Is.Null);
                    Assert.That(e.LastChangeTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.LastChangeRevision, Is.EqualTo(-1L), "Not committed yet; LastChangeRevision = -1"); // Not committed yet
                    Assert.That(e.Lock, Is.Null);
                    Assert.That(e.NodeKind, Is.EqualTo(SvnNodeKind.File));
                    Assert.That(e.Path, Is.Not.Null);
                    Assert.That(e.PropertyEditFile, Is.Null);
                    //Assert.That(e.PropertyTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.ContentTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.RepositorySize, Is.EqualTo(-1L));
                    Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri), "Repository valid");
                    Assert.That(e.Revision, Is.LessThanOrEqualTo(0L), "Not committed yet");
                    Assert.That(e.Schedule, Is.EqualTo(SvnSchedule.Add));
                    Assert.That(e.Uri, Is.EqualTo(new Uri(WcUri, "InfoFile")));
                    Assert.That(e.WorkingCopySize, Is.EqualTo(-1L));
                    visited = true;
                });
                Assert.That(visited);

                SvnCommitResult commitData;
                client.Commit(wc, out commitData);
                visited = false;
                client.Info(file, delegate(object sender, SvnInfoEventArgs e)
                {
                    Assert.That(e.ChangeList, Is.Null);
                    Assert.That(e.Checksum, Is.EqualTo("da39a3ee5e6b4b0d3255bfef95601890afd80709"));
                    Assert.That(e.ConflictNew, Is.Null);
                    Assert.That(e.ConflictOld, Is.Null);
                    Assert.That(e.ConflictWork, Is.Null);
                    Assert.That(e.ContentTime, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                    Assert.That(e.CopyFromRevision, Is.EqualTo(-1L));
                    Assert.That(e.CopyFromUri, Is.Null);
                    Assert.That(e.Depth, Is.EqualTo(SvnDepth.Unknown));
                    Assert.That(e.FullPath, Is.EqualTo(file));
                    Assert.That(e.HasLocalInfo, Is.True);
                    Assert.That(e.LastChangeAuthor, Is.EqualTo(Environment.UserName));
                    Assert.That(e.LastChangeTime, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                    Assert.That(e.LastChangeRevision, Is.EqualTo(commitData.Revision));
                    Assert.That(e.Lock, Is.Null);
                    Assert.That(e.NodeKind, Is.EqualTo(SvnNodeKind.File));
                    Assert.That(e.Path, Is.Not.Null);
                    Assert.That(e.PropertyEditFile, Is.Null);
                    //Assert.That(e.PropertyTime, Is.EqualTo(e.ContentTime)); // Not static, might change
                    Assert.That(e.RepositorySize, Is.EqualTo(-1L));
                    Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                    Assert.That(e.Revision, Is.EqualTo(commitData.Revision));
                    Assert.That(e.Schedule, Is.EqualTo(SvnSchedule.Normal));
                    Assert.That(e.Uri, Is.EqualTo(new Uri(WcUri, "InfoFile")));
                    Assert.That(e.WorkingCopySize, Is.EqualTo(0L));
                    visited = true;
                });
                Assert.That(visited);

                visited = false;
                client.Info(new Uri(WcUri, "InfoFile"), delegate(object sender, SvnInfoEventArgs e)
                {
                    Assert.That(e.ChangeList, Is.Null);
                    Assert.That(e.Checksum, Is.Null);
                    Assert.That(e.ConflictNew, Is.Null);
                    Assert.That(e.ConflictOld, Is.Null);
                    Assert.That(e.ConflictWork, Is.Null);
                    Assert.That(e.ContentTime, Is.EqualTo(DateTime.MinValue));
                    Assert.That(e.CopyFromRevision, Is.LessThanOrEqualTo(0L));
                    Assert.That(e.CopyFromUri, Is.Null);
                    Assert.That(e.Depth, Is.EqualTo(SvnDepth.Unknown));
                    Assert.That(e.FullPath, Is.Null);
                    Assert.That(e.HasLocalInfo, Is.False);
                    Assert.That(e.LastChangeAuthor, Is.EqualTo(Environment.UserName));
                    Assert.That(e.LastChangeTime, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                    Assert.That(e.LastChangeTime, Is.LessThan(DateTime.UtcNow + new TimeSpan(0, 5, 0)));
                    Assert.That(e.LastChangeRevision, Is.EqualTo(commitData.Revision));
                    Assert.That(e.Lock, Is.Null);
                    Assert.That(e.NodeKind, Is.EqualTo(SvnNodeKind.File));
                    Assert.That(e.Path, Is.Not.Null);
                    Assert.That(e.PropertyEditFile, Is.Null);
                    //Assert.That(e.PropertyTime, Is.EqualTo(e.ContentTime));
                    Assert.That(e.RepositorySize, Is.EqualTo(0L));
                    Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri));
                    Assert.That(e.Revision, Is.EqualTo(commitData.Revision));
                    Assert.That(e.Schedule, Is.EqualTo(SvnSchedule.Normal));
                    Assert.That(e.Uri, Is.EqualTo(new Uri(WcUri, "InfoFile")));
                    Assert.That(e.WorkingCopySize, Is.EqualTo(-1L));
                    visited = true;
                });
                Assert.That(visited);
            }
        }