Added additional test cases to the unittest to check for files with size zero and 1 byte.

This commit is contained in:
Kenneth Skovhede
2016-03-30 20:32:47 +02:00
parent 9912616dc0
commit fcff385c35
+23 -15
View File
@@ -71,6 +71,8 @@ namespace Duplicati.UnitTest
var data = new byte[basedatasize + 500];
File.WriteAllBytes(Path.Combine(DATAFOLDER, "a"), data.Take(basedatasize).ToArray());
File.WriteAllBytes(Path.Combine(DATAFOLDER, "a0"), data.Take(0).ToArray());
File.WriteAllBytes(Path.Combine(DATAFOLDER, "a1"), data.Take(1).ToArray());
File.WriteAllBytes(Path.Combine(DATAFOLDER, "a-p1"), data.Take(basedatasize + 1).ToArray());
File.WriteAllBytes(Path.Combine(DATAFOLDER, "a-p2"), data.Take(basedatasize+ 2).ToArray());
File.WriteAllBytes(Path.Combine(DATAFOLDER, "a-p500"), data.Take(basedatasize + 500).ToArray());
@@ -97,6 +99,8 @@ namespace Duplicati.UnitTest
new Random().NextBytes(data);
File.WriteAllBytes(Path.Combine(DATAFOLDER, "b"), data.Take(basedatasize).ToArray());
File.WriteAllBytes(Path.Combine(DATAFOLDER, "b0"), data.Take(0).ToArray());
File.WriteAllBytes(Path.Combine(DATAFOLDER, "b1"), data.Take(1).ToArray());
File.WriteAllBytes(Path.Combine(DATAFOLDER, "b-p1"), data.Take(basedatasize + 1).ToArray());
File.WriteAllBytes(Path.Combine(DATAFOLDER, "b-p2"), data.Take(basedatasize + 2).ToArray());
File.WriteAllBytes(Path.Combine(DATAFOLDER, "b-p500"), data.Take(basedatasize + 500).ToArray());
@@ -114,6 +118,10 @@ namespace Duplicati.UnitTest
new Random().NextBytes(data);
File.WriteAllBytes(Path.Combine(DATAFOLDER, "c"), data.Take(basedatasize).ToArray());
new Random().NextBytes(data);
File.WriteAllBytes(Path.Combine(DATAFOLDER, "c0"), data.Take(0).ToArray());
new Random().NextBytes(data);
File.WriteAllBytes(Path.Combine(DATAFOLDER, "c1"), data.Take(1).ToArray());
new Random().NextBytes(data);
File.WriteAllBytes(Path.Combine(DATAFOLDER, "c-p1"), data.Take(basedatasize + 1).ToArray());
new Random().NextBytes(data);
File.WriteAllBytes(Path.Combine(DATAFOLDER, "c-p2"), data.Take(basedatasize + 2).ToArray());
@@ -140,17 +148,17 @@ namespace Duplicati.UnitTest
using(var c = new Library.Main.Controller("file://" + TARGETFOLDER, testopts.Expand(new { version = 0 }), null))
{
var r = c.List("*");
Console.WriteLine("Newest before deleting:");
Console.WriteLine(string.Join(Environment.NewLine, r.Files.Select(x => x.Path)));
Assert.AreEqual(34, r.Files.Count());
//Console.WriteLine("Newest before deleting:");
//Console.WriteLine(string.Join(Environment.NewLine, r.Files.Select(x => x.Path)));
Assert.AreEqual(40, r.Files.Count());
}
using(var c = new Library.Main.Controller("file://" + TARGETFOLDER, testopts.Expand(new { version = 0, no_local_db = true }), null))
{
var r = c.List("*");
Console.WriteLine("Newest without db:");
Console.WriteLine(string.Join(Environment.NewLine, r.Files.Select(x => x.Path)));
Assert.AreEqual(34, r.Files.Count());
//Console.WriteLine("Newest without db:");
//Console.WriteLine(string.Join(Environment.NewLine, r.Files.Select(x => x.Path)));
Assert.AreEqual(40, r.Files.Count());
}
@@ -164,25 +172,25 @@ namespace Duplicati.UnitTest
using(var c = new Library.Main.Controller("file://" + TARGETFOLDER, testopts.Expand(new { version = 2 }), null))
{
var r = c.List("*");
Console.WriteLine("V2 after delete:");
Console.WriteLine(string.Join(Environment.NewLine, r.Files.Select(x => x.Path)));
Assert.AreEqual(12, r.Files.Count());
//Console.WriteLine("V2 after delete:");
//Console.WriteLine(string.Join(Environment.NewLine, r.Files.Select(x => x.Path)));
Assert.AreEqual(14, r.Files.Count());
}
using(var c = new Library.Main.Controller("file://" + TARGETFOLDER, testopts.Expand(new { version = 1 }), null))
{
var r = c.List("*");
Console.WriteLine("V1 after delete:");
Console.WriteLine(string.Join(Environment.NewLine, r.Files.Select(x => x.Path)));
Assert.AreEqual(23, r.Files.Count());
//Console.WriteLine("V1 after delete:");
//Console.WriteLine(string.Join(Environment.NewLine, r.Files.Select(x => x.Path)));
Assert.AreEqual(27, r.Files.Count());
}
using(var c = new Library.Main.Controller("file://" + TARGETFOLDER, testopts.Expand(new { version = 0 }), null))
{
var r = c.List("*");
Console.WriteLine("Newest after delete:");
Console.WriteLine(string.Join(Environment.NewLine, r.Files.Select(x => x.Path)));
Assert.AreEqual(34, r.Files.Count());
//Console.WriteLine("Newest after delete:");
//Console.WriteLine(string.Join(Environment.NewLine, r.Files.Select(x => x.Path)));
Assert.AreEqual(40, r.Files.Count());
}
}
}