public void Revision_ToString()
        {
            SvnRevision revision = SvnRevision.Base;

            Assert.That(revision.ToString(), Is.EqualTo("BASE"));

            revision = SvnRevision.Committed;
            Assert.That(revision.ToString(), Is.EqualTo("COMMITTED"));

            revision = SvnRevision.Head;
            Assert.That(revision.ToString(), Is.EqualTo("HEAD"));

            revision = SvnRevision.Previous;
            Assert.That(revision.ToString(), Is.EqualTo("PREVIOUS"));

            revision = SvnRevision.None;
            Assert.That(revision.ToString(), Is.EqualTo(""));

            revision = SvnRevision.Working;
            Assert.That(revision.ToString(), Is.EqualTo("WORKING"));

            DateTime t = DateTime.UtcNow;

            revision = new SvnRevision(t);
            Assert.That(revision.ToString(), Is.EqualTo("{" + t.ToString("s", CultureInfo.InvariantCulture) + "}"));

            revision = new SvnRevision(42);
            Assert.That(revision.ToString(), Is.EqualTo("42"));
        }
Ejemplo n.º 2
0
        public void Authentication_SimpleSslCert()
        {
            using (SvnClient client = new SvnClient())
            {
                client.Authentication.Clear();
                client.Authentication.SslServerTrustHandlers   += Authenticator_SslServerTrustHandlers;
                client.Authentication.UserNamePasswordHandlers += Authenticator_UserNamePasswordHandlers;
                bool        arrived = false;
                SvnInfoArgs a       = new SvnInfoArgs();
                a.ThrowOnCancel = false;
                a.ThrowOnError  = false;

                Assert.That(client.Info(new Uri("https://svn.apache.org/repos/private/committers"), a,
                                        delegate(object sender, SvnInfoEventArgs e)
                {
                    arrived = true;
                }), Is.False);

                Assert.That(a.LastException, Is.Not.Null);
                Assert.That(a.LastException, Is.InstanceOf(typeof(SvnException)));
                Assert.That(arrived, Is.False);
                Assert.That(_serverTrustTicked);
                Assert.That(_userNamePasswordTicked);

                Assert.That(_userArgs, Is.Not.Null);
                Assert.That(_userArgs.InitialUserName, Is.Not.Null);
                Assert.That(_userArgs.Realm, Is.EqualTo("<https://svn.apache.org:443> ASF Members"));
                Assert.That(_userArgs.RealmUri, Is.EqualTo(new Uri("https://svn.apache.org/")));
            }
        }
Ejemplo n.º 3
0
        public void Log_Test14Server()
        {
            SvnLogArgs la = new SvnLogArgs();

            la.Limit = 1;

            DateTime now = DateTime.UtcNow;

            for (int i = 0; i < 20; i++)
            {
                Assert.That(Client.Log(new Uri("https://ctf.open.collab.net/svn/repos/ankhsvn"), la,
                                       delegate(object sender, SvnLogEventArgs e)
                {
                    e.Cancel = true;
                    Assert.That(e.MergeLogNestingLevel, Is.EqualTo(0));
                    Assert.That(e.Revision, Is.GreaterThan(3000L));
                    Assert.That(e.LogMessage, Is.Not.Null);
                    Assert.That(e.Time, Is.GreaterThan(new DateTime(2008, 01, 01)));
                    Assert.That(e.Author, Is.Not.Null);
                    Assert.That(e.ChangedPaths, Is.Not.Null);
                    Assert.That(e.LogOrigin, Is.Null);
                }), Is.False);
            }

            DateTime end = DateTime.UtcNow;

            Debug.WriteLine(string.Format("Time spend: {0}", end - now));
        }
Ejemplo n.º 4
0
        public void Diff_ReposDiff()
        {
            SvnSandBox sbox       = new SvnSandBox(this);
            Uri        ReposUrl   = sbox.CreateRepository(SandBoxRepository.AnkhSvnCases);
            string     clientDiff = this.RunCommand("svn", "diff -r 1:5 " + ReposUrl);

            MemoryStream outstream = new MemoryStream();
            MemoryStream errstream = new MemoryStream();

            SvnDiffArgs a = new SvnDiffArgs();

            a.ErrorStream = errstream;
            Client.Diff(ReposUrl, new SvnRevisionRange(1, 5), a, outstream);

            string err = Encoding.Default.GetString(errstream.ToArray());

            Assert.That(err, Is.EqualTo(string.Empty), "Error in diff: " + err);

            string apiDiff = Encoding.Default.GetString(outstream.ToArray());

            string[] clientLines = clientDiff.Split('\n');
            string[] apiLines    = apiDiff.Split('\n');
            Array.Sort <string>(clientLines);
            Array.Sort <string>(apiLines);

            Assert.That(apiLines, Is.EqualTo(clientLines), "Diffs differ");
        }
Ejemplo n.º 5
0
        public void WcDirMissing()
        {
            SvnSandBox      sbox           = new SvnSandBox(this);
            Uri             CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);
            string          dir            = sbox.Wc;
            SvnUpdateResult r;

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

            Directory.Move(Path.Combine(dir, "trunk"), Path.Combine(dir, "banaan"));

            SvnInfoEventArgs iaParent;
            SvnInfoEventArgs iaTrunk;

            Client.GetInfo(dir, out iaParent);
            Client.GetInfo(Path.Combine(dir, "trunk"), out iaTrunk);

            Assert.That(iaParent.FullPath, Is.EqualTo(dir));
            Assert.That(iaTrunk.FullPath, Is.Not.EqualTo(dir));
            //Assert.That(iaParent.Uri, Is.EqualTo(iaTrunk.Uri));

            SvnWorkingCopyVersion ver;
            SvnWorkingCopyClient  wcC = new SvnWorkingCopyClient();

            Assert.That(wcC.GetVersion(dir, out ver));
            Assert.That(ver, Is.Not.Null);

            Assert.That(ver.Modified, Is.True);
            Assert.That(ver.Switched, Is.False);
            Assert.That(ver.Start, Is.EqualTo(17));
            Assert.That(ver.End, Is.EqualTo(17));
            Assert.That(ver.IncompleteWorkingCopy, Is.False);
        }
Ejemplo n.º 6
0
        public void TestNotify()
        {
            SvnSandBox sbox = new SvnSandBox(this);

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

            int           n  = 0;;
            SvnUpdateArgs ua = new SvnUpdateArgs();

            ua.Notify += delegate(object sender, SvnNotifyEventArgs e)
            {
                Assert.That(e.FullPath, Is.EqualTo(WcPath));
                switch (n++)
                {
                case 0:
                    Assert.That(e.Action, Is.EqualTo(SvnNotifyAction.UpdateStarted));
                    break;

                case 1:
                    Assert.That(e.Action, Is.EqualTo(SvnNotifyAction.UpdateCompleted));
                    break;
                }
            };

            Client.Update(WcPath, ua);
            Assert.That(n, Is.EqualTo(2));

            n = 0;

            Client.Update(new string[] { WcPath }, ua);
            Assert.That(n, Is.EqualTo(2));
        }
        public void DontCanonicalizeToDotSlash()
        {
            SvnPathTarget path = new SvnPathTarget(".\\bladiebla.txt");

            Assert.That(path.TargetName, Is.EqualTo("bladiebla.txt"));

            Assert.That(Path.GetFullPath("c:\\windows\\"), Is.EqualTo("c:\\windows\\"));
            Assert.That(SvnTools.GetNormalizedFullPath("c:\\windows\\"), Is.EqualTo("C:\\windows"));

            Assert.That(SvnRevision.Base == SvnRevision.Base);
            Assert.That(SvnRevision.Base.Equals(SvnRevision.Base));
            Assert.That(SvnRevision.Base.Equals(SvnRevisionType.Base));
            Assert.That(SvnRevision.Base == SvnRevisionType.Base);

            Assert.That(SvnRevision.Working == SvnRevision.Working);
            Assert.That(SvnRevision.Working.Equals(SvnRevision.Working));
            Assert.That(SvnRevision.Working.Equals(SvnRevisionType.Working));
            Assert.That(SvnRevision.Working == SvnRevisionType.Working);

            DirectoryInfo dir = new DirectoryInfo("c:\\");

            foreach (FileInfo file in dir.GetFiles())
            {
                Assert.That(file.FullName.StartsWith("c:\\"));
            }

            dir = new DirectoryInfo("C:\\");

            foreach (FileInfo file in dir.GetFiles())
            {
                Assert.That(file.FullName.StartsWith("C:\\"));
            }
        }
Ejemplo n.º 8
0
        public void Commit_CommitWithNonAnsiCharsInLogMessage()
        {
            SvnSandBox sbox = new SvnSandBox(this);

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

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

            using (StreamWriter w = new StreamWriter(filepath))
                w.Write("Moo");

            SvnCommitArgs a = new SvnCommitArgs();

            a.LogMessage = " ¥ · £ · € · $ · ¢ · ₡ · ₢ · ₣ · ₤ · ₥ · ₦ · ₧ · ₨ · ₩ · ₪ · ₫ · ₭ · ₮ · ₯";

            Assert.That(Client.Commit(WcPath, a));

            SvnLogArgs la = new SvnLogArgs();

            la.Start = SvnRevision.Head;
            la.End   = SvnRevision.Head;

            Collection <SvnLogEventArgs> logList;

            Client.GetLog(WcPath, la, out logList);

            Assert.That(logList, Is.Not.Null);
            Assert.That(logList.Count, Is.EqualTo(1));
            Assert.That(logList[0].LogMessage, Is.EqualTo(a.LogMessage));
        }
Ejemplo n.º 9
0
        public void Commit_WithAlternateUser()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Empty);
            string user = Guid.NewGuid().ToString();

            string dir = sbox.Wc;

            using (SvnClient client = new SvnClient())
            {
                client.Authentication.Clear();
                client.Configuration.LogMessageRequired = false;

                client.Authentication.UserNameHandlers +=
                    delegate(object sender, SvnUserNameEventArgs e)
                {
                    e.UserName = user;
                };

                client.SetProperty(dir, "a", "b");

                SvnCommitResult cr;
                client.Commit(dir, out cr);

                Collection <SvnLogEventArgs> la;
                client.GetLog(dir, out la);

                Assert.That(la.Count, Is.EqualTo(2));
                Assert.That(la[0].Revision, Is.EqualTo(cr.Revision));
                Assert.That(la[0].Author, Is.EqualTo(user));
                Assert.That(la[0].LogMessage, Is.EqualTo(""));
            }
        }
Ejemplo n.º 10
0
        public void ChangeInfo_GetInfo12()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            using (SvnLookClient cl = new SvnLookClient())
            {
                SvnChangeInfoEventArgs r;
                SvnChangeInfoArgs      ia = new SvnChangeInfoArgs();

                SvnLookOrigin origin = new SvnLookOrigin(sbox.CreateRepository(SandBoxRepository.MergeScenario).LocalPath, 12);
                //ia.RetrieveChangedPaths = false; // Will fail if true

                Assert.That(cl.GetChangeInfo(origin, ia, out r));

                Assert.That(r, Is.Not.Null);
                Assert.That(r.Author, Is.EqualTo("merger"));
                Assert.That(r.Revision, Is.EqualTo(12L));
                Assert.That(r.BaseRevision, Is.EqualTo(11L));
                Assert.That(r.LogMessage, Is.EqualTo("Merge branch a - product roadmap"));

                // This is the exact time of the commit in microseconds
                DateTime shouldBe = new DateTime(2008, 1, 27, 15, 2, 26, 567, DateTimeKind.Utc).AddTicks(6830);

                Assert.That(r.Time, Is.EqualTo(shouldBe));
            }
        }
Ejemplo n.º 11
0
        public void ChangeInfo_GetInfoCompare()
        {
            SvnSandBox sbox      = new SvnSandBox(this);
            Uri        reposUri  = sbox.CreateRepository(SandBoxRepository.MergeScenario);
            string     reposPath = reposUri.LocalPath;

            using (SvnClient cl = new SvnClient())
            {
                SvnSetPropertyArgs sa = new SvnSetPropertyArgs();
                sa.BaseRevision = 17;
                sa.LogMessage   = "Message";
                cl.RemoteSetProperty(reposUri, "MyProp", "Value", sa);
            }

            for (long ii = 1; ii < 19; ii++)
            {
                using (SvnLookClient lcl = new SvnLookClient())
                    using (SvnClient cl = new SvnClient())
                    {
                        SvnChangeInfoEventArgs r;
                        SvnChangeInfoArgs      ia     = new SvnChangeInfoArgs();
                        SvnLookOrigin          origin = new SvnLookOrigin(reposPath, ii);

                        SvnLogArgs la = new SvnLogArgs();
                        la.Start = la.End = ii;

                        Collection <SvnLogEventArgs> lrc;
                        //ia.RetrieveChangedPaths = false; // Will fail if true
                        Assert.That(lcl.GetChangeInfo(origin, ia, out r));
                        Assert.That(cl.GetLog(reposUri, la, out lrc));

                        Assert.That(r, Is.Not.Null);
                        Assert.That(lrc.Count, Is.EqualTo(1));

                        SvnLogEventArgs lr = lrc[0];

                        Assert.That(r.Author, Is.EqualTo(lr.Author));
                        Assert.That(r.Revision, Is.EqualTo(lr.Revision));
                        Assert.That(r.BaseRevision, Is.EqualTo(lr.Revision - 1));
                        Assert.That(r.LogMessage, Is.EqualTo(lr.LogMessage));
                        Assert.That(r.Time, Is.EqualTo(lr.Time));

                        Assert.That(r.ChangedPaths, Is.Not.Null, "r.ChangedPaths({0})", ii);
                        Assert.That(lr.ChangedPaths, Is.Not.Null, "lr.ChangedPaths({0})", ii);

                        Assert.That(r.ChangedPaths.Count, Is.EqualTo(lr.ChangedPaths.Count));

                        for (int i = 0; i < r.ChangedPaths.Count; i++)
                        {
                            SvnChangeItem c  = r.ChangedPaths[i];
                            SvnChangeItem lc = lr.ChangedPaths[c.Path];

                            Assert.That(c.Path, Is.EqualTo(lc.Path));
                            Assert.That(c.Action, Is.EqualTo(lc.Action));
                            Assert.That(c.CopyFromPath, Is.EqualTo(lc.CopyFromPath));
                            Assert.That(c.CopyFromRevision, Is.EqualTo(lc.CopyFromRevision));
                        }
                    }
            }
        }
Ejemplo n.º 12
0
        public void List_ReadDash()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir = sbox.Wc;

            Client.CheckOut(new Uri(CollabReposUri, "trunk"), dir);

            string file = Path.Combine(dir, "File#Dash");

            File.WriteAllText(file, "######");
            Client.Add(file);
            Client.Commit(dir);

            bool touched = false;

            Client.List(file,
                        delegate(object sender, SvnListEventArgs e)
            {
                touched = true;
                Assert.That(e.RepositoryRoot, Is.Null);
                Assert.That(e.BasePath.EndsWith("/File#Dash"));
                Assert.That(e.Name, Is.EqualTo("File#Dash"));
            });

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

            using (SvnRemoteSession rc = new SvnRemoteSession())
            {
                rc.Open(CollabReposUri);
                Collection <SvnRemoteLocationSegmentEventArgs> c;
                rc.GetLocationSegments("branches/c/products/medium.html", out c);
                List <long> revs = new List <long>();

                foreach (SvnRemoteLocationSegmentEventArgs e in c)
                {
                    revs.Add(e.StartRevision);
                    revs.Add(e.EndRevision);
                    System.Diagnostics.Debug.WriteLine(string.Format("{0}: {1}", e.Uri, e.Range));
                }

                SvnRevisionLocationMap revMap;
                rc.GetLocations("branches/c/products/medium.html", revs, out revMap);

                foreach (SvnRemoteLocationSegmentEventArgs e in c)
                {
                    Assert.That(revMap.Contains(e.StartRevision));
                    Assert.That(revMap[e.StartRevision].Uri, Is.EqualTo(e.Uri));
                    Assert.That(revMap.Contains(e.EndRevision));
                    Assert.That(revMap[e.EndRevision].Uri, Is.EqualTo(e.Uri));
                }
            }
        }
Ejemplo n.º 14
0
        protected SvnClient NewSvnClient(bool expectCommit, bool expectConflict)
        {
            SvnClient client = new SvnClient();

            client.Conflict += delegate(object sender, SvnConflictEventArgs e)
            {
                Assert.That(true, Is.EqualTo(expectConflict), "Conflict expected");
            };

            client.Committing += delegate(object sender, SvnCommittingEventArgs e)
            {
                Assert.That(true, Is.EqualTo(expectCommit), "Commit expected");
                if (e.LogMessage == null)
                {
                    e.LogMessage = "";
                }

                GC.KeepAlive(e.Items);
            };

            SetupAuth(client);

            client.Notify += OnClientNotify;

            return(client);
        }
Ejemplo n.º 15
0
        public void Path_NormalizePathSharpFail()
        {
            string result       = null;
            bool   gotException = false;

            try
            {
                result = SvnTools.GetNormalizedFullPath("c:\\<>\\..\\123456789012345678901234567890123456789012345678901234567890" +
                                                        "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
                                                        "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
                                                        "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
                                                        "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +
                                                        "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
            }
            catch (ArgumentException)
            {
                Assert.That(Environment.Version.Major, Is.LessThan(4));
                gotException = true;
            }

            if (Environment.Version.Major >= 4)
            {
                Assert.That(result, Is.Not.Null);
            }
            else
            {
                Assert.That(gotException, "Got exception");
            }
        }
Ejemplo n.º 16
0
        public void Copy_ReposCopy()
        {
            SvnSandBox sbox     = new SvnSandBox(this);
            Uri        reposUri = sbox.CreateRepository(SandBoxRepository.Default);
            Uri        trunk    = new Uri(reposUri, "trunk/");
            Uri        branch   = new Uri(reposUri, "my-branches/new-branch");

            SvnCopyArgs ca = new SvnCopyArgs();

            ca.LogMessage    = "Message";
            ca.CreateParents = true;
            Client.RemoteCopy(trunk, branch, ca);

            int n = 0;

            Client.List(branch, delegate(object sender, SvnListEventArgs e)
            {
                if (e.Entry.NodeKind == SvnNodeKind.File)
                {
                    n++;
                }
            });

            Assert.That(n, Is.GreaterThan(0), "Copied files");
        }
Ejemplo n.º 17
0
        public void Path_UriStrangeness()
        {
            // Somehow the behavior reverts to 2.0 like for the VS Test runner?
            if (Environment.Version.Major < 4 || (TestContext != null))
            {
                // This is where we wrote this test for
                Assert.That(new Uri("http://server/file.").AbsoluteUri, Is.EqualTo("http://server/file"));
                Assert.That(new Uri("http://server/dir./file.").AbsoluteUri, Is.EqualTo("http://server/dir/file"));
                Assert.That(new Uri("http://server/file.").OriginalString, Is.EqualTo("http://server/file."));
                Assert.That(new Uri("http://server/dir./file.").OriginalString, Is.EqualTo("http://server/dir./file."));
                Assert.That(new Uri("http://server/").AbsoluteUri, Is.EqualTo("http://server/"));
                Assert.That(new Uri("http://server/").OriginalString, Is.EqualTo("http://server/"));
                Assert.That(new Uri("http://server").AbsoluteUri, Is.EqualTo("http://server/"));
                Assert.That(new Uri("http://server").OriginalString, Is.EqualTo("http://server"));

                Assert.That(new Uri("http://server/file%2E").AbsoluteUri, Is.EqualTo("http://server/file"));
            }
            else
            {
                // And in .Net 4.0 many strange cases are gone
                Assert.That(new Uri("http://server/file.").AbsoluteUri, Is.EqualTo("http://server/file."));
                Assert.That(new Uri("http://server/dir./file.").AbsoluteUri, Is.EqualTo("http://server/dir./file."));
                Assert.That(new Uri("http://server/file.").OriginalString, Is.EqualTo("http://server/file."));
                Assert.That(new Uri("http://server/dir./file.").OriginalString, Is.EqualTo("http://server/dir./file."));
                Assert.That(new Uri("http://server/").AbsoluteUri, Is.EqualTo("http://server/"));
                Assert.That(new Uri("http://server/").OriginalString, Is.EqualTo("http://server/"));
                Assert.That(new Uri("http://server").AbsoluteUri, Is.EqualTo("http://server/"));
                Assert.That(new Uri("http://server").OriginalString, Is.EqualTo("http://server"));

                Assert.That(new Uri("http://server/file%2E").AbsoluteUri, Is.EqualTo("http://server/file."));
            }
        }
Ejemplo n.º 18
0
        public void WriteProps()
        {
            SvnSandBox sbox = new SvnSandBox(this);

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

            string data = Guid.NewGuid().ToString();

            using (SvnClient client = NewSvnClient(true, false))
            {
                string file = Path.Combine(WcPath, "WriteTest");
                using (StreamWriter sw = File.CreateText(file))
                {
                    sw.WriteLine(data);
                }

                client.Add(file);
                client.SetProperty(file, "A", "B");
                client.Commit(file);

                using (MemoryStream ms = new MemoryStream())
                {
                    SvnPropertyCollection pc;
                    client.Write(new SvnPathTarget(file, SvnRevision.Head), ms, out pc);

                    Assert.That(pc, Is.Not.Empty);
                    Assert.That(pc["A"].StringValue, Is.EqualTo("B"));
                }
            }
        }
Ejemplo n.º 19
0
        public void UpdateInUse()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir = sbox.Wc;

            Client.CheckOut(new SvnUriTarget(new Uri(CollabReposUri, "trunk"), 1), dir);

            using (File.OpenRead(Path.Combine(dir, "index.html")))
                using (new Implementation.SvnFsOperationRetryOverride(0))
                {
                    SvnSystemException se = null;
                    try
                    {
                        Client.Update(Path.Combine(dir, "index.html"));
                        Assert.Fail("Should have failed");
                    }
                    catch (SvnWorkingCopyException e)
                    {
                        Assert.That(e.Message, Is.StringContaining("Failed to run the WC DB"));
                        se = e.GetCause <SvnSystemException>();
                    }
                    catch (SvnSystemException e)
                    {
                        se = e;
                    }

                    Assert.That(se, Is.Not.Null, "Have system exception");
                    Assert.That(se.Message, Is.StringContaining("Can't move"));
                }
        }
Ejemplo n.º 20
0
        public void TestCatPeg()
        {
            SvnSandBox sbox     = new SvnSandBox(this);
            Uri        reposUri = new Uri(sbox.CreateRepository(SandBoxRepository.AnkhSvnCases), "trunk/");

            Uri path   = new Uri(reposUri, "Form.cs");
            Uri toPath = new Uri(reposUri, "Moo.cs");

            SvnCommitResult ci;

            this.Client.RemoteMove(path, toPath, out ci);

            string clientOutput = this.RunCommand("svn",
                                                  string.Format("cat {0}@{1} -r {2}", toPath, ci.Revision, ci.Revision - 1));

            MemoryStream stream = new MemoryStream();
            SvnWriteArgs a      = new SvnWriteArgs();

            a.Revision = ci.Revision - 1;
            this.Client.Write(new SvnUriTarget(toPath, ci.Revision), stream);

            string wrapperOutput = Encoding.ASCII.GetString(stream.ToArray());

            Assert.That(wrapperOutput, Is.EqualTo(clientOutput),
                        "String from wrapper not the same as string from client");
        }
Ejemplo n.º 21
0
        public void Diff_LocalDiff()
        {
            SvnSandBox sbox = new SvnSandBox(this);

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

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


            using (StreamWriter w = new StreamWriter(form, false))
                w.Write("Moo moo moo moo moo\r\nmon\r\nmooo moo moo \r\nssdgo");

            //Necessary to fix up headers

            string clientDiff = this.RunCommand("svn", "diff \"" + form + "\"");

            MemoryStream outstream = new MemoryStream();
            MemoryStream errstream = new MemoryStream();

            SvnDiffArgs a = new SvnDiffArgs();

            a.ErrorStream = errstream;
            this.Client.Diff(
                new SvnPathTarget(form, SvnRevision.Base),
                new SvnPathTarget(form, SvnRevision.Working),
                a, outstream);

            string err = Encoding.Default.GetString(errstream.ToArray());

            Assert.That(err, Is.EqualTo(""), "Error in diff: " + err);
            string apiDiff = Encoding.Default.GetString(outstream.ToArray());

            Assert.That(apiDiff, Is.EqualTo(clientDiff), "Client diff differs");
        }
Ejemplo n.º 22
0
        public void TestPropGetOnFile()
        {
            SvnSandBox sbox = new SvnSandBox(this);

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

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

            TouchFile(path);
            Client.Add(path);
            Client.SetProperty(path, "foo", "bar");

            string value;

            Assert.That(Client.GetProperty(new SvnPathTarget(path), "foo", out value));

            Assert.That(value, Is.EqualTo("bar"));

            SvnPropertyValue pval;

            Assert.That(Client.GetProperty(new SvnPathTarget(path), "foo", out pval));

            Assert.That(pval.StringValue, Is.EqualTo("bar"));
            Assert.That(pval.Key, Is.EqualTo("foo"));
            Assert.That(pval.Target.TargetName, Is.EqualTo(path));
        }
Ejemplo n.º 23
0
        public void TestChangeAdministrativeDirectoryName()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.AnkhSvnCases);

            string       newAdminDir = "_svn";
            PropertyInfo pi          = typeof(SvnClient).GetProperty("AdministrativeDirectoryName", BindingFlags.SetProperty | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);

            Assert.That(pi, Is.Not.Null);

            pi.SetValue(null, newAdminDir, null);
            try
            {
                Assert.That(SvnClient.AdministrativeDirectoryName, Is.EqualTo(newAdminDir),
                            "Admin directory name should now be " + newAdminDir);

                string newwc = sbox.GetTempDir();
                this.Client.CheckOut(sbox.RepositoryUri, newwc);

                Assert.That(Directory.Exists(Path.Combine(newwc, newAdminDir)),
                            "Admin directory with new name not found");

                Assert.That(Directory.Exists(Path.Combine(newwc, ".svn")), Is.False,
                            "Admin directory with old name found");
            }
            finally
            {
                pi.SetValue(null, ".svn", null);
                Assert.That(SvnClient.AdministrativeDirectoryName, Is.EqualTo(".svn"), "Settings original admin dir failed");
            }
        }
        public void Capabilities_Local()
        {
            SvnSandBox sbox            = new SvnSandBox(this);
            Uri        emptyUri        = sbox.CreateRepository(SandBoxRepository.Empty);
            Uri        emptyNoMergeUri = sbox.CreateRepository(SandBoxRepository.EmptyNoMerge);


            using (SvnClient client = new SvnClient())
            {
                Collection <SvnCapability> caps;
                SvnGetCapabilitiesArgs     aa = new SvnGetCapabilitiesArgs();
                aa.RetrieveAllCapabilities = true;

                IEnumerable <SvnCapability> rCaps = new SvnCapability[] { SvnCapability.MergeInfo };
                Assert.That(client.GetCapabilities(emptyUri, rCaps, out caps));

                Assert.That(caps.Contains(SvnCapability.MergeInfo));

                Assert.That(client.GetCapabilities(emptyNoMergeUri, rCaps, out caps));

                Assert.That(!caps.Contains(SvnCapability.MergeInfo));
                Assert.That(caps.Count, Is.EqualTo(0));

                Assert.That(client.GetCapabilities(emptyNoMergeUri, aa, out caps));
                Assert.That(caps.Count, Is.GreaterThanOrEqualTo(5));

                Assert.That(client.GetCapabilities(emptyUri, aa, out caps));
                Assert.That(caps.Count, Is.GreaterThanOrEqualTo(6));
            }
        }
Ejemplo n.º 25
0
        private void OnChangedProps(object sender, ReposHookEventArgs e)
        {
            using (SvnLookClient look = new SvnLookClient())
            {
                int i = 0;
                look.InheritedPropertyList(e.HookArgs.LookOrigin, "trunk/A/mu",
                                           delegate(object sender2, SvnLookInheritedPropertyListEventArgs ee)
                {
                    switch (i++)
                    {
                    case 0:
                        Assert.That(ee.Path, Is.EqualTo("trunk"));
                        Assert.That(ee.Properties.Contains("root-A"));
                        break;

                    case 1:
                        Assert.That(ee.Path, Is.EqualTo("trunk/A"));
                        Assert.That(ee.Properties.Contains("A-A"));
                        break;

                    case 2:
                        Assert.That(ee.Path, Is.EqualTo("trunk/A/mu"));
                        Assert.That(ee.Properties.Contains("mu-A"));
                        break;

                    default:
                        throw new InvalidOperationException("Too many invocations");
                    }
                });

                Assert.That(i, Is.GreaterThan(0), "No props listed");
            }
        }
Ejemplo n.º 26
0
        public void PegTests()
        {
            SvnSandBox sbox           = new SvnSandBox(this);
            Uri        CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir = sbox.Wc;

            SvnUpdateResult result;

            Assert.That(Client.CheckOut(new SvnUriTarget(new Uri(CollabReposUri, "trunk")), dir, out result));

            long head = result.Revision;

            Assert.That(result.Revision, Is.EqualTo(head));

            Assert.That(Client.Switch(dir, new SvnUriTarget(new Uri(CollabReposUri, "branches/a")), out result));
            Assert.That(result.Revision, Is.EqualTo(head));

            Assert.That(Client.Switch(dir, new SvnUriTarget(new Uri(CollabReposUri, "branches/c"), head - 3), out result));
            Assert.That(result.Revision, Is.EqualTo(head - 3));

            SvnSwitchArgs sa = new SvnSwitchArgs();

            sa.Revision = head - 4;
            Assert.That(Client.Switch(dir, new SvnUriTarget(new Uri(CollabReposUri, "branches/b"), head - 5), sa, out result));
            Assert.That(result.Revision, Is.EqualTo(head - 4));

            sa          = new SvnSwitchArgs();
            sa.Revision = head - 7;
            Assert.That(Client.Switch(dir, new SvnUriTarget(new Uri(CollabReposUri, "branches/a")), sa, out result));
            Assert.That(result.Revision, Is.EqualTo(head - 7));
        }
Ejemplo n.º 27
0
        public void Log_LogFromFile()
        {
            SvnSandBox sbox  = new SvnSandBox(this);
            Uri        repos = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir = sbox.Wc;

            using (SvnClient client = new SvnClient())
            {
                client.CheckOut(new Uri(repos, "trunk/"), dir);

                int n = 0;
                client.Log(Path.Combine(dir, "index.html"),
                           delegate(object sender, SvnLogEventArgs e)
                {
                    switch (n++)
                    {
                    case 0:
                        Assert.That(e.LogMessage, Is.EqualTo("Merge branch b - product roadmap and update about page"));
                        break;

                    case 1:
                        Assert.That(e.LogMessage, Is.EqualTo("Merge branch a.  Added medium product"));
                        break;

                    case 2:
                        Assert.That(e.LogMessage, Is.EqualTo("Create initial product structure"));
                        break;
                    }
                });
                Assert.That(n, Is.EqualTo(3));
            }
        }
Ejemplo n.º 28
0
        public void Dump_DumpDb()
        {
            SvnSandBox sbox  = new SvnSandBox(this);
            string     repos = sbox.GetTempDir();

            using (SvnRepositoryClient cl = new SvnRepositoryClient())
            {
                SvnCreateRepositoryArgs ra = new SvnCreateRepositoryArgs();
                ra.RepositoryType          = SvnRepositoryFileSystem.BerkeleyDB;
                ra.RepositoryCompatibility = SvnRepositoryCompatibility.Subversion10;

                cl.CreateRepository(repos, ra);

                string file = GetTempFile();
                using (FileStream s = File.Create(file))
                {
                    SvnDumpRepositoryArgs da = new SvnDumpRepositoryArgs();
                    da.Start = new SvnRevision(0);
                    da.End   = new SvnRevision(SvnRevisionType.Head);
                    cl.DumpRepository(repos, s, da);
                }

                Assert.That(new FileInfo(file).Length, Is.GreaterThan(12));
            }
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Does it match the LogMessage object
 /// </summary>
 /// <param name="msg"></param>
 public void CheckMatch(SvnLogEventArgs e)
 {
     Assert.That(e.Author, Is.EqualTo(this.author), "Author differs");
     Assert.That(e.LogMessage, Is.EqualTo(this.message), "Message differs");
     Assert.That(e.Revision, Is.EqualTo(this.revision), "Revision differs");
     Assert.That(e.Time, Is.EqualTo(this.date), "Date differs");
 }
Ejemplo n.º 30
0
        public void CheckOut_TestPeg()
        {
            SvnSandBox sbox     = new SvnSandBox(this);
            Uri        reposUri = sbox.CreateRepository(SandBoxRepository.DefaultBranched);
            Uri        trunk    = new Uri(reposUri, "trunk/");

            SvnUpdateResult result;

            Assert.That(Client.CheckOut(trunk, sbox.GetTempDir(), out result));

            Assert.That(result, Is.Not.Null);
            long head = result.Revision;

            Assert.That(Client.CheckOut(new SvnUriTarget(trunk, 1), sbox.GetTempDir(), out result));
            Assert.That(result.Revision, Is.EqualTo(1));

            SvnCheckOutArgs a = new SvnCheckOutArgs();

            a.Revision = 1;

            Assert.That(Client.CheckOut(new SvnUriTarget(new Uri(reposUri, "branches/trunk-r2"), 4), sbox.GetTempDir(), a, out result));
            Assert.That(result.Revision, Is.EqualTo(1));

            Assert.That(Client.CheckOut(trunk, sbox.GetTempDir(), a, out result));
            Assert.That(result.Revision, Is.EqualTo(1));
        }