public void Remote_RemoteList() { DateTime start = DateTime.Now; using (SvnRemoteSession rc = new SvnRemoteSession()) { rc.Open(new Uri("http://svn.apache.org/repos/asf/subversion/")); int n = 0; bool foundTrunk = false; List <Uri> uris = new List <Uri>(); SvnNodeKind dir; rc.GetNodeKind("", out dir); Assert.That(dir, Is.EqualTo(SvnNodeKind.Directory)); rc.List("", delegate(object sender, SvnRemoteListEventArgs e) { n++; if (e.Name == "trunk") { foundTrunk = true; Assert.That(e.Uri, Is.EqualTo(new Uri("http://svn.apache.org/repos/asf/subversion/trunk/"))); } uris.Add(e.Uri); }); Assert.That(foundTrunk); Assert.That(n, Is.GreaterThan(4)); Uri reposRoot; rc.GetRepositoryRoot(out reposRoot); rc.Reparent(reposRoot); int n2 = 0; rc.List("subversion/", delegate(object sender, SvnRemoteListEventArgs e) { n2++; Assert.That(uris.Contains(e.Uri), "Same Uri"); }); Assert.That(n2, Is.EqualTo(n)); } DateTime between = DateTime.Now; Collection <SvnListEventArgs> items; Client.GetList(new Uri("http://svn.apache.org/repos/asf/subversion/"), out items); DateTime after = DateTime.Now; Console.WriteLine(between - start); Console.WriteLine(after - between); }
public void Diff_DiffBinary() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.AnkhSvnCases); string WcPath = sbox.Wc; string path = Path.Combine(WcPath, "Form.cs"); this.RunCommand("svn", "propset svn:mime-type application/octet-stream " + path); this.RunCommand("svn", "ci -m '' " + path); using (StreamWriter w = new StreamWriter(path)) w.WriteLine("Hi there"); MemoryStream outstream = new MemoryStream(); MemoryStream errstream = new MemoryStream(); SvnDiffArgs a = new SvnDiffArgs(); a.ErrorStream = errstream; // this should not diff a binary file Assert.That(Client.Diff( path, new SvnRevisionRange(SvnRevision.Base, SvnRevision.Working), a, outstream)); string diff = Encoding.ASCII.GetString(outstream.ToArray()); Assert.That(diff.IndexOf("application/octet-stream") >= 0); outstream = new MemoryStream(); errstream = new MemoryStream(); a = new SvnDiffArgs(); a.ErrorStream = errstream; a.IgnoreContentType = true; this.Client.Diff( path, new SvnRevisionRange(SvnRevision.Base, SvnRevision.Working), a, outstream); Assert.That(outstream.Length > 0); diff = Encoding.ASCII.GetString(outstream.ToArray()); Assert.That(diff.IndexOf("application/octet-stream") < 0); }
public void TestUuidFromPath() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Empty); string WcPath = sbox.Wc; Guid id; Assert.That(this.Client.TryGetRepositoryId(WcPath, out id)); Assert.That(id, Is.Not.EqualTo(Guid.Empty), "UUID wrong"); }
public void CreateDirectory_MakeLocalDir() { SvnSandBox sbox = new SvnSandBox(this); Uri emptyUri = sbox.CreateRepository(SandBoxRepository.Empty); Client.CheckOut(emptyUri, sbox.Wc); string path = Path.Combine(sbox.Wc, "foo"); Assert.That(Client.CreateDirectory(path)); Assert.That(this.GetSvnStatus(path), Is.EqualTo(SvnStatus.Added), "Wrong status code"); }
public void Can_Add_An_Identifier() { // Arrange const string identifier = "FirstName"; // Act Slapper.AutoMapper.Configuration.AddIdentifier(typeof(IdentifierTestModels.Customer), identifier); var identifiers = Slapper.AutoMapper.InternalHelpers.GetIdentifiers(typeof(IdentifierTestModels.Customer)); // Assert Assert.That(identifiers.First() == identifier); }
public void CheckOut_ProgressEvent() { SvnSandBox sbox = new SvnSandBox(this); string newWc = sbox.GetTempDir(); SvnCheckOutArgs a = new SvnCheckOutArgs(); bool progressCalled = false; a.Progress += delegate(object sender, SvnProgressEventArgs e) { progressCalled = true; }; a.Depth = SvnDepth.Empty; this.Client.CheckOut(new Uri("http://svn.apache.org/repos/asf/subversion/"), newWc, a); Assert.That(progressCalled, "Progress delegate not called"); }
public void ListSsh() { using (SvnClient client = new SvnClient()) { bool foundOne = false; client.List(new Uri("svn+ssh://vip.alh.net.qqn.nl/home/bert/repos/"), delegate(object sender, SvnListEventArgs e) { foundOne = true; }); Assert.That(foundOne); } }
public void TestUrlFromDirPath() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Default); string WcPath = sbox.Wc; string info = this.RunCommand("svn", "info " + WcPath); string realUrl = this.GetUrl(WcPath); Uri url = this.Client.GetUriFromWorkingCopy(WcPath); Assert.That(url.ToString(), Is.EqualTo(realUrl + "/"), "URL wrong"); }
public void TestUrlFromFilePath() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.AnkhSvnCases); string WcPath = sbox.Wc; string formPath = Path.Combine(WcPath, "Form.cs"); string realUrl = this.GetUrl(formPath); Uri url = this.Client.GetUriFromWorkingCopy(formPath); Assert.That(url.ToString(), Is.EqualTo(realUrl), "URL wrong"); }
public void TestUuidFromUrl() { SvnSandBox sbox = new SvnSandBox(this); Uri repositoryUri = sbox.CreateRepository(SandBoxRepository.Empty); Guid id; Guid newId = Guid.NewGuid(); new SvnRepositoryClient().SetRepositoryId(repositoryUri.AbsolutePath, newId); Assert.That(this.Client.TryGetRepositoryId(repositoryUri, out id)); Assert.That(id, Is.EqualTo(newId), "UUID wrong"); }
public void CreateDirectory_MakeRepositoryDir() { SvnSandBox sbox = new SvnSandBox(this); Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.Empty); Uri url = new Uri(ReposUrl, "mooNewDirectory/"); Assert.That(Client.RemoteCreateDirectory(url)); bool gotOne = false; Client.List(url, delegate(object sender, SvnListEventArgs e) { gotOne = true; }); Assert.That(gotOne); }
public void TestSwitchUrl() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.AnkhSvnCases); string WcPath = sbox.Wc; Uri switchUrl = new Uri(sbox.RepositoryUri, "trunk/doc"); string checkFile = Path.Combine(WcPath, "text_r5.txt"); this.Client.Switch(WcPath, switchUrl); Assert.That(File.Exists(checkFile), "Didn't switch to repos/doc"); }
public void WriteTest() { 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.AddToChangeList(file, "WriteTest-Items"); SvnCommitArgs ca = new SvnCommitArgs(); ca.ChangeLists.Add("WriteTest-Items"); client.Commit(WcPath); using (MemoryStream ms = new MemoryStream()) { client.Write(new SvnPathTarget(file), ms); ms.Position = 0; using (StreamReader sr = new StreamReader(ms)) { Assert.That(sr.ReadLine(), Is.EqualTo(data)); Assert.That(sr.ReadToEnd(), Is.EqualTo("")); } } using (MemoryStream ms = new MemoryStream()) { client.Write(new Uri(sbox.RepositoryUri, "WriteTest"), ms); ms.Position = 0; using (StreamReader sr = new StreamReader(ms)) { Assert.That(sr.ReadLine(), Is.EqualTo(data)); Assert.That(sr.ReadToEnd(), Is.EqualTo("")); } } } }
public void StaticVerifications_VerifyEnums() { Assembly asm = typeof(SvnClient).Assembly; Hashtable ignoreTypes = new Hashtable(); ignoreTypes.Add(typeof(SvnErrorCode), asm); ignoreTypes.Add(typeof(SvnWindowsErrorCode), asm); ignoreTypes.Add(typeof(SvnChangeAction), asm); ignoreTypes.Add(typeof(SvnAprErrorCode), asm); foreach (Type tp in asm.GetTypes()) { if (!tp.IsEnum || !tp.IsPublic || ignoreTypes.Contains(tp)) { continue; } if (tp.GetCustomAttributes(typeof(FlagsAttribute), false).Length == 1 || Enum.GetUnderlyingType(tp) != typeof(int)) { continue; } Assert.That(Enum.IsDefined(tp, 0), "0 value is defined in {0}", tp); int min = 0; int max = 0; foreach (int v in Enum.GetValues(tp)) { if (v < min) { min = v; } if (v > max) { max = v; } } if (tp == typeof(SvnCommandType)) { max = (int)SvnCommandType.Write; } for (int i = min; i <= max; i++) { Assert.That(Enum.IsDefined(tp, i), "{0} value is defined in {1}", i, tp); } } }
public void RevisionProperty_RevSetPropDir() { SvnSandBox sbox = new SvnSandBox(this); Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.Empty); sbox.InstallRevpropHook(ReposUrl); byte[] propval = Encoding.UTF8.GetBytes("moo"); this.Client.SetRevisionProperty(ReposUrl, SvnRevision.Head, "cow", propval); Assert.That(this.RunCommand("svn", "propget cow --revprop -r head " + ReposUrl).Trim(), Is.EqualTo("moo"), "Couldn't set prop on selected Repos!"); }
public void List_RemoteListTest() { SvnSandBox sbox = new SvnSandBox(this); Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.Greek); using (SvnClient client = NewSvnClient(false, false)) { Collection <SvnListEventArgs> items; client.GetList(ReposUrl, out items); Assert.That(items, Is.Not.Null, "Items retrieved"); Assert.That(items.Count, Is.GreaterThan(0), "More than 0 items"); } }
public void List_TestList() { SvnSandBox sbox = new SvnSandBox(this); Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.AnkhSvnCases); string list = this.RunCommand("svn", "list -v " + ReposUrl); // clean out whitespace string[] entries = Regex.Split(list, @"\r\n"); //string[] entries = list.Trim().Split( '\n' ); Hashtable ht = new Hashtable(); foreach (string e in entries) { if (e != "") { Entry ent = new Entry(e); ht[ent.Path] = ent; } } Collection <SvnListEventArgs> apiList; SvnListArgs a = new SvnListArgs(); a.Depth = SvnDepth.Children; Assert.That(Client.GetList(new SvnUriTarget(ReposUrl, SvnRevision.Head), a, out apiList)); Assert.That(apiList.Count, Is.EqualTo(ht.Count), "Wrong number of entries returned"); foreach (SvnListEventArgs ent in apiList) { string path = ent.Path; if (path == "") { break; // New in 1.4+ ; was not available in ankh tests, as svn_client_ls was used instead of svn_client_list } if (ent.Entry.NodeKind == SvnNodeKind.Directory) { path += "/"; } Entry entry = (Entry)ht[path]; Assert.IsNotNull(entry, "No entry found for " + path); entry.Match(ent.Entry); } }
public void List_TestRoot() { SvnSandBox sbox = new SvnSandBox(this); Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); using (SvnClient client = new SvnClient()) { client.List(CollabReposUri, delegate(object sender, SvnListEventArgs e) { Assert.That(e.RepositoryRoot, Is.EqualTo(CollabReposUri)); Assert.That(e.RepositoryRoot.ToString().EndsWith("/")); }); } }
public void GetRepositoryId() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Default); Guid id; Assert.That(Client.TryGetRepositoryId(sbox.Wc, out id), "Can get id"); Assert.That(id, Is.Not.EqualTo(Guid.Empty)); Assert.That(Client.TryGetRepositoryId(Path.Combine(sbox.Wc, "AA"), out id), Is.False, "No Id"); Assert.That(id, Is.EqualTo(Guid.Empty)); }
public void DiffSummary_TrunkBranchB() { SvnSandBox sbox = new SvnSandBox(this); Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); SvnDiffSummaryArgs sa = new SvnDiffSummaryArgs(); Client.DiffSummary(new Uri(CollabReposUri, "trunk"), new Uri(CollabReposUri, "branches/b"), sa, delegate(object sender, SvnDiffSummaryEventArgs e) { Assert.That(e.FromUri.ToString().StartsWith(CollabReposUri.ToString())); Assert.That(e.ToUri.ToString().StartsWith(CollabReposUri.ToString())); }); }
public void TestDeletedFile() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.AnkhSvnCases); string WcPath = sbox.Wc; string filePath = Path.Combine(WcPath, "Form.cs"); File.Delete(filePath); this.Client.Update(WcPath); Assert.That(File.Exists(filePath), "File not restored after update"); }
public void Path_SshUsernameTests() { Assert.That(SvnTools.GetNormalizedUri(new Uri(new Uri("http://[email protected]/"), "/trunk")).AbsoluteUri, Is.EqualTo("http://[email protected]/trunk")); SvnUriTarget target = new SvnUriTarget(new Uri("http://[email protected]/home/user/repos/"), 1234); Assert.That(target.Revision.RevisionType, Is.EqualTo(SvnRevisionType.Number)); Assert.That(target.Uri.AbsoluteUri, Is.EqualTo("http://[email protected]/home/user/repos")); SvnUriTarget target2 = new SvnUriTarget(new Uri("http://[email protected]:123/home/user/repos/"), SvnRevisionType.Head); Assert.That(target2.Revision, Is.EqualTo(SvnRevision.Head)); Assert.That(target2.Uri.AbsoluteUri, Is.EqualTo("http://[email protected]:123/home/user/repos")); }
private void OnPreCommitBigFile(object sender, ReposHookEventArgs e) { using (SvnLookClient cl = new SvnLookClient()) { using (MemoryStream ms = new MemoryStream()) { cl.Write(e.HookArgs.LookOrigin, "/bigfile", ms); } string b_p; Assert.That(cl.GetProperty(e.HookArgs.LookOrigin, "/bigfile", "a", out b_p)); Assert.That(b_p, Is.EqualTo("b")); } }
void OnPostCommit(object sender, ReposHookEventArgs e) { using (SvnLookClient cl = new SvnLookClient()) { SvnChangeInfoArgs ia = new SvnChangeInfoArgs(); SvnChangeInfoEventArgs i; Assert.That(cl.GetChangeInfo(e.HookArgs.LookOrigin, ia, out i)); GC.KeepAlive(i); Assert.That(i.Revision, Is.GreaterThanOrEqualTo(0L)); Assert.That(i.Author, Is.EqualTo(Environment.UserName)); } }
public void InfoYoungest() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.AnkhSvnCases); long rev; Assert.That(Client.Youngest(sbox.Uri, out rev)); Assert.That(rev, Is.EqualTo(6)); Assert.That(Client.Youngest(sbox.Wc, out rev)); Assert.That(rev, Is.EqualTo(6)); }
public void Capabilities_SharpCaps() { using (SvnClient client = new SvnClient()) { Collection <SvnCapability> caps; SvnGetCapabilitiesArgs ca = new SvnGetCapabilitiesArgs(); ca.RetrieveAllCapabilities = true; Assert.That(client.GetCapabilities(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn"), ca, out caps)); Assert.That(caps.Contains(SvnCapability.MergeInfo)); Assert.That(caps.Count, Is.GreaterThanOrEqualTo(5)); } }
public void ParseReturn() { SvnExternalItem item; string txt = new SvnExternalItem("a b c", "http://host/path with space/").ToString(); Assert.That(SvnExternalItem.TryParse(txt, out item)); Assert.That(item.Target, Is.EqualTo("a b c")); Assert.That(item.Reference, Is.EqualTo("http://host/path with space/")); txt = new SvnExternalItem("'a b c\"", "http://host/path with \"\'/").ToString(); Assert.That(SvnExternalItem.TryParse(txt, out item)); Assert.That(item.Target, Is.EqualTo("'a b c\"")); Assert.That(item.Reference, Is.EqualTo("http://host/path with \"\'/")); }
public void List_TestHash() { using (SvnClient client = NewSvnClient(false, false)) { Uri reposUri = new Uri("https://ctf.open.collab.net/svn/repos/ankhsvn/"); string baseUri = "https://ctf.open.collab.net/svn/repos/ankhsvn/testcases/trunk/WorstCase/AllTypesSolution/"; string exUri = baseUri + "%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%9f%e3%83%b3%e3%82%b0%23Silverlight/"; bool found = false; client.List(new SvnUriTarget(new Uri(baseUri), 11888), delegate(object sender, SvnListEventArgs e) { if (string.IsNullOrEmpty(e.Path)) { Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri)); return; } if (e.Uri == new Uri(exUri)) { found = true; } }); Assert.That(found, "Found subdir"); found = false; client.List(new SvnUriTarget(new Uri(baseUri), 11888), delegate(object sender, SvnListEventArgs e) { if (string.IsNullOrEmpty(e.Path)) { Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri)); Assert.That(e.BaseUri, Is.EqualTo(new Uri(baseUri))); return; } }); client.List(new SvnUriTarget(new Uri(exUri + "Properties/"), 11888), delegate(object sender, SvnListEventArgs e) { if (string.IsNullOrEmpty(e.Path)) { Assert.That(e.RepositoryRoot, Is.EqualTo(reposUri)); Assert.That(e.BaseUri, Is.EqualTo(new Uri(exUri + "Properties/"))); return; } }); } }
public void Path_TestNormalizationTesters() { Assert.That(SvnTools.IsNormalizedFullPath("a:\\"), Is.False, "a:\\ is not normalized"); Assert.That(SvnTools.IsNormalizedFullPath("A:\\"), Is.True, "A:\\ is normalized"); Assert.That(SvnTools.IsNormalizedFullPath("A:\\\\"), Is.False, "A:\\\\ is not normalized"); Assert.That(SvnTools.IsNormalizedFullPath("A:\\.\\"), Is.False); Assert.That(SvnTools.IsNormalizedFullPath("A:\\..\\"), Is.False); Assert.That(SvnTools.IsNormalizedFullPath("A:\\...\\"), Is.False); Assert.That(SvnTools.IsNormalizedFullPath("A:\\..."), Is.False); Assert.That(SvnTools.IsNormalizedFullPath("A:\\.svn"), Is.True); Assert.That(SvnTools.IsNormalizedFullPath("A:\\.svn\\"), Is.False); Assert.That(SvnTools.IsNormalizedFullPath("A:\\\\t.svn"), Is.False); Assert.That(SvnTools.IsNormalizedFullPath("A:\\.....svn"), Is.True); Assert.That(SvnTools.GetTruePath("c:\\"), Is.EqualTo("C:\\")); Assert.That(SvnTools.GetTruePath("c:\\" + Guid.NewGuid()), Is.Null); Assert.That(SvnTools.GetTruePath("c:\\-never-exists-", true), Is.Not.Null); Assert.That(SvnTools.IsAbsolutePath("a:\\"), Is.True); Assert.That(SvnTools.IsAbsolutePath("A:\\"), Is.True); Assert.That(SvnTools.IsAbsolutePath("A:\\\\"), Is.False); Assert.That(SvnTools.IsAbsolutePath("A:\\B"), Is.True); Assert.That(SvnTools.IsAbsolutePath("A:\\B\\"), Is.False); Assert.That(SvnTools.IsAbsolutePath("a:/sdfsdfsd"), Is.True); Assert.That(SvnTools.IsAbsolutePath("A:\\dfsdfds"), Is.True); Assert.That(SvnTools.IsAbsolutePath("a:"), Is.False); Assert.That(SvnTools.IsAbsolutePath("A:file"), Is.False); Assert.That(Path.IsPathRooted("a:"), Is.True); Assert.That(Path.IsPathRooted("A:file"), Is.True); Assert.That(SvnTools.IsNormalizedFullPath(@"\\SERVER\path"), Is.False, @"\\SERVER\path"); Assert.That(SvnTools.IsNormalizedFullPath(@"\\server\path\"), Is.False, @"\\server\path\"); Assert.That(SvnTools.IsNormalizedFullPath(@"\\server\path"), Is.True, @"\\server\path"); Assert.That(SvnTools.IsNormalizedFullPath(@"\\server\Path"), Is.True, @"\\server\Path"); Assert.That(SvnTools.IsNormalizedFullPath(@"\\server\path\file"), Is.True); Assert.That(SvnTools.IsAbsolutePath(@"\\\"), Is.False); Assert.That(SvnTools.IsAbsolutePath(@"\\server\path"), Is.True); Assert.That(SvnTools.IsAbsolutePath(@"\\server\path\"), Is.False); Assert.That(SvnTools.IsAbsolutePath(@"\\server\path\\"), Is.False); Assert.That(SvnTools.IsAbsolutePath(@"\\server\path\dir"), Is.True); Assert.That(SvnTools.IsAbsolutePath(@"\\server\path\dir\"), Is.False); Assert.That(SvnTools.IsAbsolutePath(@"\\server\path\dir\\"), Is.False); Assert.That(SvnTools.IsAbsolutePath(@"\\server"), Is.False); Assert.That(SvnTools.IsAbsolutePath(@"\\server\"), Is.False); Assert.That(SvnTools.IsAbsolutePath(@"\\server\\"), Is.False); Assert.That(SvnTools.IsAbsolutePath(@"\server"), Is.False); }
public void Can_Detect_Duplicate_Parent_Members_And_Properly_Instantiate_The_Object_Only_Once() { // Arrange const int id = 1; const string firstName = "Bob"; const string lastName = "Smith"; const int orderId = 1; const decimal orderTotal = 50.50m; var dictionary = new Dictionary <string, object> { { "Id", id }, { "FirstName", firstName }, { "LastName", lastName }, { "Orders_Id", orderId }, { "Orders_OrderTotal", orderTotal } }; var dictionary2 = new Dictionary <string, object> { { "Id", id }, { "FirstName", firstName }, { "LastName", lastName }, { "Orders_Id", orderId + 1 }, { "Orders_OrderTotal", orderTotal + 1 } }; var listOfDictionaries = new List <Dictionary <string, object> > { dictionary, dictionary2 }; // Act var customers = Slapper.AutoMapper.Map <MapTestModels.CustomerWithOrdersList>(listOfDictionaries); var customer = customers.FirstOrDefault(); // Assert Assert.That(customers.Count() == 1); Assert.NotNull(customer); Assert.That(customer.Id == id); Assert.That(customer.FirstName == firstName); Assert.That(customer.LastName == lastName); Assert.NotNull(customer.Orders); Assert.That(customer.Orders.Count == 2); Assert.That(customer.Orders[0].Id == orderId); Assert.That(customer.Orders[0].OrderTotal == orderTotal); Assert.That(customer.Orders[1].Id == orderId + 1); Assert.That(customer.Orders[1].OrderTotal == orderTotal + 1); }