Skip to content

Commit ac10d81

Browse files
committed
Add recursive pull test compares names
1 parent 15cb3fd commit ac10d81

File tree

4 files changed

+60
-53
lines changed

4 files changed

+60
-53
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ bld/
3434

3535
# Visual Studio 2015/2017 cache/options directory
3636
.vs/
37+
.vs
3738
# Uncomment if you have tasks that create the project's static files in wwwroot
3839
#wwwroot/
3940

.vs/SyncSVN/v16/.suo

-316 KB
Binary file not shown.
-24 Bytes
Binary file not shown.

SyncSVNTests/SVNFileRepositoryTests.cs

+59-53
Original file line numberDiff line numberDiff line change
@@ -62,98 +62,64 @@ private string GetRelativePath(string filespec, string folder)
6262
return Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', Path.DirectorySeparatorChar));
6363
}
6464

65-
public void PullTestRec(string DirUrl, string DirLocalPath)
66-
{
67-
68-
}
69-
70-
[TestCleanup]
71-
public void TestCleanup()
72-
{
73-
var dir = new System.IO.DirectoryInfo(config.configData["RootPath"]);
74-
if (dir.Exists) {
75-
setAttributesNormal(dir);
76-
dir.Delete(true);
77-
dir.Create();
78-
}
79-
}
8065

81-
/**
82-
* Test download specific file
83-
*/
84-
[TestMethod()]
85-
public void DownloadTest()
86-
{
87-
88-
List<string> files = new List<string> { "asd.txt", "New_File.txt" };
89-
try {
90-
// Test downoad file
91-
foreach (var file in files)
92-
repo.Download(file);
93-
94-
} catch (Exception e) {
95-
Assert.Fail("Exception occured: " + e.Message + "\n");
96-
}
97-
}
98-
99-
/**
100-
* Test pull content from remove repository
101-
*/
102-
[TestMethod()]
103-
public void PullTest()
66+
public void PullTestRec(string DirUrl, string DirLocalPath)
10467
{
10568
List<string> files = new List<string>();
10669
List<string> directories = new List<string>();
10770
using (SvnClient svnClient = new SvnClient()) {
10871
SvnInfoEventArgs info;
109-
Uri repos = new Uri(config.configData["SvnUrl"]);
72+
Uri repos = new Uri(DirUrl);
11073
svnClient.GetInfo(repos, out info);
111-
74+
11275
Collection<SvnListEventArgs> contents;
11376
SvnListArgs arg = new SvnListArgs();
11477
arg.Revision = new SvnRevision(info.Revision); //the revision you want to check
11578
arg.RetrieveEntries = SvnDirEntryItems.AllFieldsV15;
116-
if (svnClient.GetList(new Uri(config.configData["SvnUrl"]), arg, out contents)) {
79+
if (svnClient.GetList(new Uri(DirUrl), arg, out contents)) {
11780
foreach (SvnListEventArgs item in contents) {
11881
if (item.Entry.NodeKind == SvnNodeKind.Directory)
11982
directories.Add(item.Path);
12083
else if (item.Entry.NodeKind == SvnNodeKind.File)
12184
files.Add(item.Path);
122-
}
85+
}
12386
}
12487
}
12588

12689
directories = directories.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();
12790
directories.Sort();
91+
foreach (var dir in directories)
92+
PullTestRec(Path.Combine(DirUrl, dir), Path.Combine(DirLocalPath, dir));
93+
12894
files.Sort();
129-
95+
13096
repo.Pull();
131-
132-
string rootPath = config.configData["RootPath"];
97+
98+
string rootPath = DirLocalPath;
13399
List<string> localFiles = Directory.GetFiles(rootPath)
134100
.OfType<string>().ToList();
135101
List<string> localDirectories = Directory.GetDirectories(rootPath)
136102
.OfType<string>().ToList();
137-
103+
138104
for (int i = 0; i < localFiles.Count; ++i)
139105
localFiles[i] = GetRelativePath(localFiles[i], rootPath);
140-
106+
141107
for (int i = 0; i < localDirectories.Count; ++i)
142108
localDirectories[i] = GetRelativePath(localDirectories[i], rootPath);
143-
109+
144110
localDirectories.RemoveAll(dir => dir == ".svn");
145111
localDirectories.Sort();
146112
localFiles.Sort();
147-
148-
113+
114+
149115
Console.WriteLine("Remote files");
150-
foreach(var file in files)
116+
foreach (var file in files)
151117
Console.WriteLine(file);
152118
Console.WriteLine("Remote directories");
153119
foreach (var dir in directories)
154120
Console.WriteLine(dir);
155-
156-
121+
122+
157123
Console.WriteLine("Local files");
158124
foreach (var file in localFiles)
159125
Console.WriteLine(file);
@@ -166,6 +132,46 @@ public void PullTest()
166132
CollectionAssert.AreEqual(localFiles, files);
167133
CollectionAssert.AreEqual(localDirectories, directories);
168134
}
135+
136+
[TestCleanup]
137+
public void TestCleanup()
138+
{
139+
var dir = new System.IO.DirectoryInfo(config.configData["RootPath"]);
140+
if (dir.Exists) {
141+
setAttributesNormal(dir);
142+
dir.Delete(true);
143+
dir.Create();
144+
}
145+
}
146+
147+
148+
/// <summary>
149+
/// Test download specific file
150+
/// </summary>
151+
[TestMethod()]
152+
public void DownloadTest()
153+
{
154+
155+
List<string> files = new List<string> { "asd.txt", "New_File.txt" };
156+
try {
157+
// Test downoad file
158+
foreach (var file in files)
159+
repo.Download(file);
160+
161+
} catch (Exception e) {
162+
Assert.Fail("Exception occured: " + e.Message + "\n");
163+
}
164+
}
165+
166+
/// <summary>
167+
/// Test pull content from remove repository recursively
168+
/// Test compare each directory or file name in remote repository with local
169+
/// </summary>
170+
[TestMethod()]
171+
public void PullTest()
172+
{
173+
PullTestRec(config.configData["SvnUrl"], config.configData["RootPath"]);
174+
}
169175

170176
[TestMethod()]
171177
public void PushTest()

0 commit comments

Comments
 (0)