Skip to content
Snippets Groups Projects
Commit d89d2c30 authored by L. Ellenbeck's avatar L. Ellenbeck
Browse files

Refactoring of Namepaces and solutions coscine/issues#83

parent d424b450
Branches Sprint/2020-10
No related tags found
1 merge request!2Product/75 s3 zip metadata
...@@ -5,11 +5,11 @@ using System.Runtime.InteropServices; ...@@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("cs-S3Zip.Tests")] [assembly: AssemblyTitle("Coscine.S3Zip.Tests")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("cs-S3Zip.Tests")] [assembly: AssemblyProduct("Coscine.S3Zip.Tests")]
[assembly: AssemblyCopyright("Copyright © 2019")] [assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
<ProjectGuid>{6B58EB5E-D857-464B-8174-C17375BAE1CF}</ProjectGuid> <ProjectGuid>{6B58EB5E-D857-464B-8174-C17375BAE1CF}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>coscine.cs_S3Zip.Tests</RootNamespace> <RootNamespace>Coscine.S3Zip.Tests</RootNamespace>
<AssemblyName>cs-S3Zip.Tests</AssemblyName> <AssemblyName>Coscine.S3Zip.Tests</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\cs-S3Zip\cs-S3Zip.csproj"> <ProjectReference Include="..\S3Zip\S3Zip.csproj">
<Project>{7AC0CBDF-046B-496E-931B-776678098C7E}</Project> <Project>{7AC0CBDF-046B-496E-931B-776678098C7E}</Project>
<Name>cs-S3Zip</Name> <Name>cs-S3Zip</Name>
</ProjectReference> </ProjectReference>
......
...@@ -6,23 +6,23 @@ using System; ...@@ -6,23 +6,23 @@ using System;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
namespace coscine.cs_S3Zip.Tests namespace Coscine.S3Zip.Tests
{ {
[TestFixture] [TestFixture]
public class S3ZipTests public class S3ZipTests
{ {
private readonly S3MultipartStreamConfiguration _s3MultipartStreamConfiguration; private readonly S3MultipartStreamConfiguration _s3MultipartStreamConfiguration;
private readonly char[] charArray; private readonly char[] _charArray;
private readonly int ONE_MB; private readonly int _ONE_MB;
public S3ZipTests() public S3ZipTests()
{ {
var accessKey = Environment.GetEnvironmentVariable("S3_ACCESS_KEY", EnvironmentVariableTarget.Process); var accessKey = Environment.GetEnvironmentVariable("S3_ACCESS_KEY", EnvironmentVariableTarget.Process);
var secretKey = Environment.GetEnvironmentVariable("S3_SECRET_KEY", EnvironmentVariableTarget.Process); var secretKey = Environment.GetEnvironmentVariable("S3_SECRET_KEY", EnvironmentVariableTarget.Process);
charArray = "$%#@!*abcdefghijklmnopqrstuvwxyz1234567890?;:ABCDEFGHIJKLMNOPQRSTUVWXYZ^&".ToCharArray(); _charArray = "$%#@!*abcdefghijklmnopqrstuvwxyz1234567890?;:ABCDEFGHIJKLMNOPQRSTUVWXYZ^&".ToCharArray();
ONE_MB = (int)Math.Pow(2, 20); _ONE_MB = (int)Math.Pow(2, 20);
_s3MultipartStreamConfiguration = new S3MultipartStreamConfiguration _s3MultipartStreamConfiguration = new S3MultipartStreamConfiguration
{ {
...@@ -72,17 +72,17 @@ namespace coscine.cs_S3Zip.Tests ...@@ -72,17 +72,17 @@ namespace coscine.cs_S3Zip.Tests
var key = "S3MultipartUploadStreamTest.txt"; var key = "S3MultipartUploadStreamTest.txt";
var seed = DateTime.Now.Millisecond; var seed = DateTime.Now.Millisecond;
var random = new Random(seed); var random = new Random(seed);
var randomBuffer = new byte[ONE_MB]; var randomBuffer = new byte[_ONE_MB];
var oldChunkSize = _s3MultipartStreamConfiguration.ChunckSize; var oldChunkSize = _s3MultipartStreamConfiguration.ChunckSize;
_s3MultipartStreamConfiguration.ChunckSize = chunkSize * ONE_MB; _s3MultipartStreamConfiguration.ChunckSize = chunkSize * _ONE_MB;
using (var s3Stream = new S3MultipartUploadStream(key, _s3MultipartStreamConfiguration)) using (var s3Stream = new S3MultipartUploadStream(key, _s3MultipartStreamConfiguration))
{ {
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
FillArrayWithRandomChars(randomBuffer, randomBuffer.Length, charArray, random); FillArrayWithRandomChars(randomBuffer, randomBuffer.Length, _charArray, random);
s3Stream.Write(randomBuffer, 0, ONE_MB); s3Stream.Write(randomBuffer, 0, _ONE_MB);
} }
} }
...@@ -94,7 +94,7 @@ namespace coscine.cs_S3Zip.Tests ...@@ -94,7 +94,7 @@ namespace coscine.cs_S3Zip.Tests
// reset the random number generator // reset the random number generator
random = new Random(seed); random = new Random(seed);
var buffer = new byte[ONE_MB]; var buffer = new byte[_ONE_MB];
using (var client = new AmazonS3Client(_s3MultipartStreamConfiguration.AccessKey, _s3MultipartStreamConfiguration.SecretKey, _s3MultipartStreamConfiguration.AmazonS3Config)) using (var client = new AmazonS3Client(_s3MultipartStreamConfiguration.AccessKey, _s3MultipartStreamConfiguration.SecretKey, _s3MultipartStreamConfiguration.AmazonS3Config))
{ {
...@@ -112,7 +112,7 @@ namespace coscine.cs_S3Zip.Tests ...@@ -112,7 +112,7 @@ namespace coscine.cs_S3Zip.Tests
// Was request successfull? // Was request successfull?
Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK);
// Has the correct length? // Has the correct length?
Assert.IsTrue(response.ContentLength == length * ONE_MB); Assert.IsTrue(response.ContentLength == length * _ONE_MB);
using (var responseStream = response.ResponseStream) using (var responseStream = response.ResponseStream)
{ {
...@@ -120,7 +120,7 @@ namespace coscine.cs_S3Zip.Tests ...@@ -120,7 +120,7 @@ namespace coscine.cs_S3Zip.Tests
while (alreadyRead < length * buffer.Length) while (alreadyRead < length * buffer.Length)
{ {
int read = responseStream.Read(buffer, 0, buffer.Length); int read = responseStream.Read(buffer, 0, buffer.Length);
FillArrayWithRandomChars(randomBuffer, read, charArray, random); FillArrayWithRandomChars(randomBuffer, read, _charArray, random);
// check if the data is equal to the previously generated one. // check if the data is equal to the previously generated one.
Assert.IsTrue(Enumerable.SequenceEqual(randomBuffer.Take(read), buffer.Take(read))); Assert.IsTrue(Enumerable.SequenceEqual(randomBuffer.Take(read), buffer.Take(read)));
alreadyRead += read; alreadyRead += read;
...@@ -141,23 +141,23 @@ namespace coscine.cs_S3Zip.Tests ...@@ -141,23 +141,23 @@ namespace coscine.cs_S3Zip.Tests
var key = "S3MultipartDownloadStreamTest.txt"; var key = "S3MultipartDownloadStreamTest.txt";
var seed = DateTime.Now.Millisecond; var seed = DateTime.Now.Millisecond;
var random = new Random(seed); var random = new Random(seed);
var randomBuffer = new byte[ONE_MB]; var randomBuffer = new byte[_ONE_MB];
var oldChunkSize = _s3MultipartStreamConfiguration.ChunckSize; var oldChunkSize = _s3MultipartStreamConfiguration.ChunckSize;
_s3MultipartStreamConfiguration.ChunckSize = chunkSize * ONE_MB; _s3MultipartStreamConfiguration.ChunckSize = chunkSize * _ONE_MB;
using (var s3Stream = new S3MultipartUploadStream(key, _s3MultipartStreamConfiguration)) using (var s3Stream = new S3MultipartUploadStream(key, _s3MultipartStreamConfiguration))
{ {
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
FillArrayWithRandomChars(randomBuffer, randomBuffer.Length, charArray, random); FillArrayWithRandomChars(randomBuffer, randomBuffer.Length, _charArray, random);
s3Stream.Write(randomBuffer, 0, ONE_MB); s3Stream.Write(randomBuffer, 0, _ONE_MB);
} }
} }
// reset the random number generator // reset the random number generator
random = new Random(seed); random = new Random(seed);
var buffer = new byte[ONE_MB]; var buffer = new byte[_ONE_MB];
using (var client = new AmazonS3Client(_s3MultipartStreamConfiguration.AccessKey, _s3MultipartStreamConfiguration.SecretKey, _s3MultipartStreamConfiguration.AmazonS3Config)) using (var client = new AmazonS3Client(_s3MultipartStreamConfiguration.AccessKey, _s3MultipartStreamConfiguration.SecretKey, _s3MultipartStreamConfiguration.AmazonS3Config))
{ {
...@@ -176,7 +176,7 @@ namespace coscine.cs_S3Zip.Tests ...@@ -176,7 +176,7 @@ namespace coscine.cs_S3Zip.Tests
while (alreadyRead < length * buffer.Length) while (alreadyRead < length * buffer.Length)
{ {
int read = s3MultipartDownloadStream.Read(buffer, 0, buffer.Length); int read = s3MultipartDownloadStream.Read(buffer, 0, buffer.Length);
FillArrayWithRandomChars(randomBuffer, read, charArray, random); FillArrayWithRandomChars(randomBuffer, read, _charArray, random);
// check if the data is equal to the previously generated one. // check if the data is equal to the previously generated one.
Assert.IsTrue(Enumerable.SequenceEqual(randomBuffer.Take(read), buffer.Take(read))); Assert.IsTrue(Enumerable.SequenceEqual(randomBuffer.Take(read), buffer.Take(read)));
alreadyRead += read; alreadyRead += read;
......
...@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 ...@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156 VisualStudioVersion = 16.0.28803.156
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs-S3Zip", "cs-S3Zip\cs-S3Zip.csproj", "{7AC0CBDF-046B-496E-931B-776678098C7E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S3Zip", "S3Zip\S3Zip.csproj", "{7AC0CBDF-046B-496E-931B-776678098C7E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs-S3Zip.Tests", "cs-S3Zip.Tests\cs-S3Zip.Tests.csproj", "{6B58EB5E-D857-464B-8174-C17375BAE1CF}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S3Zip.Tests", "S3Zip.Tests\S3Zip.Tests.csproj", "{6B58EB5E-D857-464B-8174-C17375BAE1CF}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
...@@ -5,11 +5,11 @@ using System.Runtime.InteropServices; ...@@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("cs-S3Zip")] [assembly: AssemblyTitle("Coscine.S3Zip")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("cs-S3Zip")] [assembly: AssemblyProduct("Coscine.S3Zip")]
[assembly: AssemblyCopyright("Copyright © 2019")] [assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
......
using Amazon.S3; using Amazon.S3;
using Amazon.S3.Model; using Amazon.S3.Model;
using System;
using System.IO; using System.IO;
namespace coscine.cs_S3Zip namespace Coscine.S3Zip
{ {
public class S3MultipartDownloadStream : Stream public class S3MultipartDownloadStream : Stream
{ {
......
using Amazon.S3; using Amazon.S3;
using System; using System;
namespace coscine.cs_S3Zip namespace Coscine.S3Zip
{ {
public class S3MultipartStreamConfiguration public class S3MultipartStreamConfiguration
{ {
......
...@@ -4,7 +4,7 @@ using System; ...@@ -4,7 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
namespace coscine.cs_S3Zip namespace Coscine.S3Zip
{ {
public class S3MultipartUploadStream : Stream public class S3MultipartUploadStream : Stream
{ {
......
...@@ -7,11 +7,12 @@ ...@@ -7,11 +7,12 @@
<ProjectGuid>{7AC0CBDF-046B-496E-931B-776678098C7E}</ProjectGuid> <ProjectGuid>{7AC0CBDF-046B-496E-931B-776678098C7E}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>coscine.cs_S3Zip</RootNamespace> <RootNamespace>Coscine.S3Zip</RootNamespace>
<AssemblyName>cs-S3Zip</AssemblyName> <AssemblyName>cs-S3Zip</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
namespace coscine.cs_S3Zip namespace Coscine.S3Zip
{ {
public class ZipUtilities public class ZipUtilities
{ {
......
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment