Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
JensDll committed Nov 6, 2023
1 parent dfd4772 commit 9640eee
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,24 +161,29 @@ public async Task BadRequestForInvalidFormData()
Assert.That(encodeResponse.Content.Headers.ContentType?.MediaType, Is.EqualTo("application/json"));
}

private static File[] GetFiles(params int[] sizes) => sizes.Select((size, i) =>
private static File[] GetFiles(params int[] sizes)
{
byte[] content = new byte[size];
Random.Shared.NextBytes(content);
File file = new()
return sizes.Select((size, i) =>
{
Name = $"file@{i + 1}.txt",
Content = content,
Size = size
};
return file;
}).ToArray();
byte[] content = new byte[size];
Random.Shared.NextBytes(content);
File file = new()
{
Name = $"file@{i + 1}.txt",
Content = content,
Size = size
};
return file;
}).ToArray();
}

private static int GetMessageLength(IEnumerable<File> files) =>
private static int GetMessageLength(IEnumerable<File> files)
{
// File length + file name length + file name + file
files.Sum(file => 4 + 2 + Encoding.UTF8.GetByteCount(file.Name) + file.Content.Length);
return files.Sum(file => 4 + 2 + Encoding.UTF8.GetByteCount(file.Name) + file.Content.Length);
}

private sealed class File
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ public class DecodeRequest

public static async ValueTask<DecodeRequest?> BindAsync(HttpContext context)
{
MultipartReader? multipartReader = MultipartReader.Create(context);
DecodeEndpoint endpoint = context.RequestServices.GetRequiredService<DecodeEndpoint>();

if (multipartReader is null)
MultipartReader multipartReader = new(context, endpoint);

if (endpoint.HasValidationError)
{
return null;
}
Expand Down Expand Up @@ -52,7 +54,7 @@ public class DecodeRequest

string key = await formSection.GetValueAsync(cancellationToken);

return new DecodeRequest()
return new DecodeRequest
{
CoverImage = coverImage,
CoverImageCapacity = coverImage.Width * coverImage.Height * 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ public class EncodeBinaryRequest

public static async ValueTask<EncodeBinaryRequest?> BindAsync(HttpContext context)
{
MultipartReader? multipartReader = MultipartReader.Create(context);
DecodeEndpoint endpoint = context.RequestServices.GetRequiredService<DecodeEndpoint>();

if (multipartReader is null)
MultipartReader multipartReader = new(context, endpoint);

if (endpoint.HasValidationError)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ public class EncodeTextRequest

public static async ValueTask<EncodeTextRequest?> BindAsync(HttpContext context)
{
MultipartReader? multipartReader = MultipartReader.Create(context);
DecodeEndpoint endpoint = context.RequestServices.GetRequiredService<DecodeEndpoint>();

if (multipartReader is null)
MultipartReader multipartReader = new(context, endpoint);

if (endpoint.HasValidationError)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ProjectReference Include="..\steganography.domain\steganography.domain.csproj"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MinimalApiBuilder" Version="2.0.0"/>
<PackageReference Include="MinimalApiBuilder" Version="3.0.0"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
</ItemGroup>
</Project>

0 comments on commit 9640eee

Please sign in to comment.