Skip to content

Commit

Permalink
Merge pull request #35 from mattosaurus/development
Browse files Browse the repository at this point in the history
Aysnc updates and large file handling
  • Loading branch information
mattosaurus authored Aug 28, 2019
2 parents dc7f769 + 5f015c8 commit 0ff8aab
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 120 deletions.
11 changes: 7 additions & 4 deletions PgpCore.Tests/PgpCore.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
Expand All @@ -7,9 +7,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 9 additions & 6 deletions PgpCore.Tests/UnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using Org.BouncyCastle.Bcpg.OpenPgp;
using Xunit;

Expand Down Expand Up @@ -924,14 +925,16 @@ private void CreateRandomFile(string filePath, int sizeInMb)
const int blocksPerMb = (1024 * 1024) / blockSize;

byte[] data = new byte[blockSize];
Random rng = new Random();
using (FileStream stream = File.OpenWrite(filePath))

using (RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider())
{
// There
for (int i = 0; i < sizeInMb * blocksPerMb; i++)
using (FileStream stream = File.OpenWrite(filePath))
{
rng.NextBytes(data);
stream.Write(data, 0, data.Length);
for (int i = 0; i < sizeInMb * blocksPerMb; i++)
{
crypto.GetBytes(data);
stream.Write(data, 0, data.Length);
}
}
}
}
Expand Down
Loading

0 comments on commit 0ff8aab

Please sign in to comment.