1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// Copyright (C) 2015, The Duplicati Team
// http://www.duplicati.com, info@duplicati.com
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using NUnit.Framework;
using System.Linq;
using System.IO;
using System;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using Duplicati.Library.Utility;
namespace Duplicati.UnitTest
{
public class GeneralBlackBoxTesting : BasicSetupHelper
{
private static readonly string SOURCE_FOLDERS = Path.Combine(BASEFOLDER, "DSMCBE");
private readonly string zipFilename = "DSMCBE.zip";
private string zipFilepath => Path.Combine(BASEFOLDER, this.zipFilename);
protected IEnumerable<string> TestFolders
{
get
{
var rx = new System.Text.RegularExpressions.Regex("r(?<number>\\d+)");
return
from n in Directory.EnumerateDirectories(SOURCE_FOLDERS)
let m = rx.Match(n)
where m.Success
orderby int.Parse(m.Groups["number"].Value)
select n;
}
}
protected override Dictionary<string, string> TestOptions
{
get
{
return TestUtils.DefaultOptions;
}
}
protected string TestTarget
{
get
{
var x = TestUtils.GetDefaultTarget("x");
return x == "x" ? null : x;
}
}
public override void OneTimeSetUp()
{
base.OneTimeSetUp();
using (WebClient client = new WebClient())
{
client.DownloadFile($"https://s3.amazonaws.com/duplicati-test-file-hosting/{this.zipFilename}", this.zipFilepath);
}
System.IO.Compression.ZipFile.ExtractToDirectory(this.zipFilepath, BASEFOLDER);
}
public override void OneTimeTearDown()
{
if (Directory.Exists(SOURCE_FOLDERS))
{
Directory.Delete(SOURCE_FOLDERS, true);
}
if (File.Exists(this.zipFilepath))
{
File.Delete(this.zipFilepath);
}
}
[Test]
[Category("SVNData")]
public void TestWithSVNShort()
{
SVNCheckoutTest.RunTest(TestFolders.Take(5).ToArray(), TestOptions, TestTarget);
}
[Test]
[Category("SVNDataLong")]
public void TestWithSVNLong()
{
SVNCheckoutTest.RunTest(TestFolders.ToArray(), TestOptions, TestTarget);
}
[Test]
[Category("SVNData")]
public void TestWithErrors()
{
var u = new Library.Utility.Uri(TestUtils.GetDefaultTarget());
RandomErrorBackend.WrappedBackend = u.Scheme;
var target = u.SetScheme(new RandomErrorBackend().ProtocolKey).ToString();
SVNCheckoutTest.RunTest(TestFolders.Take(5).ToArray(), TestOptions, target);
}
[Test]
[Category("SVNData")]
public void TestWithoutSizeInfo()
{
var u = new Library.Utility.Uri(TestUtils.GetDefaultTarget());
SizeOmittingBackend.WrappedBackend = u.Scheme;
var target = u.SetScheme(new SizeOmittingBackend().ProtocolKey).ToString();
SVNCheckoutTest.RunTest(TestFolders.Take(5).ToArray(), TestOptions, target);
}
}
}
|