diff --git a/Source/TargetBinaryStorage/InMemoryBinaryStorage/BinaryStorage.cs b/Source/TargetBinaryStorage/InMemoryBinaryStorage/BinaryStorage.cs index af87e87..868ae04 100644 --- a/Source/TargetBinaryStorage/InMemoryBinaryStorage/BinaryStorage.cs +++ b/Source/TargetBinaryStorage/InMemoryBinaryStorage/BinaryStorage.cs @@ -9,7 +9,7 @@ { private Dictionary Blobs { get; } = new Dictionary(); - private Dictionary Blocks { get; } = new Dictionary(); + private Dictionary Blocks { get; } = new Dictionary(); public Task GetBlobIfExists(string blobId) { @@ -33,13 +33,13 @@ { return Task.Run(() => { - this.Blocks[new BlockId(blobId, blockKey)] = new BlockInfo(blobId, partNumber, blockKey, block); + this.Blocks[new BlockId(blobId, blockKey)] = block; }); } public Task RetrieveBlock(string blobId, string blockKey) { - return Task.Run(() => this.Blocks[new BlockId(blobId, blockKey)].BlockData); + return Task.Run(() => this.Blocks[new BlockId(blobId, blockKey)]); } } } diff --git a/Source/TargetBinaryStorage/InMemoryBinaryStorage/BlockInfo.cs b/Source/TargetBinaryStorage/InMemoryBinaryStorage/BlockInfo.cs deleted file mode 100644 index 068e769..0000000 --- a/Source/TargetBinaryStorage/InMemoryBinaryStorage/BlockInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace EternalArrowBackup.TargetBinaryStorage.InMemoryBinaryStorage -{ - internal class BlockInfo - { - public BlockInfo(string blobId, int partNumber, string blockKey, byte[] blockData) - { - this.BlobId = blobId; - this.PartNumber = partNumber; - this.BlockKey = blockKey; - this.BlockData = blockData; - } - - public string BlobId { get; } - - public int PartNumber { get; } - - public string BlockKey { get; } - - public byte[] BlockData { get; } - } -} diff --git a/Tests/ContentTransformer/ClearText/DataWithSignatureTests.cs b/Tests/ContentTransformer/ClearText/DataWithSignatureTests.cs new file mode 100644 index 0000000..dd249b8 --- /dev/null +++ b/Tests/ContentTransformer/ClearText/DataWithSignatureTests.cs @@ -0,0 +1,22 @@ +namespace EternalArrowBackup.ContentTransformer.ClearText.Tests +{ + using System; + using Xunit; + + public static class DataWithSignatureTests + { + [Fact] + [Trait("Category", "Simple")] + public static void TestDataWithSignatureConstructor() + { + Assert.ThrowsAny(() => new DataWithSignature(null, new byte[0])); + Assert.ThrowsAny(() => new DataWithSignature(new byte[0], null)); + Assert.ThrowsAny(() => new DataWithSignature(new byte[0], new byte[65536])); + Assert.ThrowsAny(() => new DataWithSignature(new byte[0], new byte[100000])); + new DataWithSignature(new byte[0], new byte[0]); + new DataWithSignature(new byte[100], new byte[100]); + new DataWithSignature(new byte[1000], new byte[65535]); + new DataWithSignature(new byte[100000], new byte[65535]); + } + } +} diff --git a/Tests/ContentTransformer/ClearText/EncryptorAndHasherTests.cs b/Tests/ContentTransformer/ClearText/EncryptorAndHasherTests.cs index b479d49..1eee6bc 100644 --- a/Tests/ContentTransformer/ClearText/EncryptorAndHasherTests.cs +++ b/Tests/ContentTransformer/ClearText/EncryptorAndHasherTests.cs @@ -1,5 +1,6 @@ namespace EternalArrowBackup.ContentTransformer.ClearText.Tests { + using System; using System.Text; using System.Threading.Tasks; using EternalArrowBackup.Hasher.Sha256; @@ -26,11 +27,13 @@ encrypted[0]++; decryptionResult = await encryptor.GetOriginalData(encrypted); Assert.False(decryptionResult.IsSuccessful); + Assert.Throws(() => decryptionResult.Data); encrypted[0]--; encrypted[encrypted.Length - 1]--; decryptionResult = await encryptor.GetOriginalData(encrypted); Assert.False(decryptionResult.IsSuccessful); + Assert.Throws(() => decryptionResult.Data); } } }