Skip to content
Snippets Groups Projects
Commit 0164b630 authored by Klaus Fischer's avatar Klaus Fischer
Browse files

feature: add max file size finder

parent 48f85dec
No related branches found
No related tags found
1 merge request!112Draft: Feature/1731 big files encryption
......@@ -31,28 +31,16 @@ public class FileEncryptionTest {
_encryptedFile = _encryption.Encrypt(_sourceFile);
}
[Ignore("Test takes too long")]
[TestCase(1)]
[Ignore("Takes much to long")]
[TestCase(500)]
[TestCase(600)]
[TestCase(700)]
[TestCase(750)]
[TestCase(800)]
[TestCase(1000)]
[TestCase(2000)]
[TestCase(2047)]
public void EncryptLargeFiles_ShouldPass(int fileSizeInMb) {
Console.WriteLine($"Encrypting {int.MaxValue / (1024*1024)} MB file");
var randomdMb = "";
for (int i = 0 ; i < (1024*1024 - 1) ; i++) {
randomdMb += "a";
}
var maxString = "";
for (int i = 0; i < int.MaxValue / (1024*1024); i++) {
maxString += randomdMb;
}
Console.WriteLine($"Max String is {maxString.Length / (1024*1024)} MB long");
// Arrange
var sourceFile = RandomNumberGenerator.GetBytes(1024 * 1024 * fileSizeInMb);
Console.WriteLine($"Encrypting {fileSizeInMb} MB file");
......@@ -65,7 +53,24 @@ public class FileEncryptionTest {
// Assert
encryptedFile.Should().NotBeNullOrEmpty();
}
[Ignore("Takes much to long")]
[Test]
public void FindMaxFileSizeForEncryption() {
for (var start = 750; start < 800; start++) {
Console.Write($"Trying to encrypt {start} MB file");
try {
EncryptLargeFiles_ShouldPass(start);
Console.WriteLine("...success");
}
catch (Exception e) {
Console.WriteLine("...failed");
Console.WriteLine(e);
Console.WriteLine($"Max file size for encryption is {start - 1} MB");
break;
}
}
}
[Test]
......@@ -102,7 +107,9 @@ public class FileEncryptionTest {
}";
Assert.Throws<EncryptionException>(() => {
var result = new FitEncryption(new List<string> { "" }, "", null)
var result = new FitEncryption(new List<string> {
""
}, "", null)
.Encrypt("Test", jsonWebKeyString);
Console.WriteLine(result);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment