Skip to content

Commit

Permalink
Minor refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
jezzsantos committed Dec 1, 2024
1 parent c59219f commit 318c497
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/BookingsApplication/BookingsApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public async Task<Result<Error>> CancelBookingAsync(ICallerContext caller, strin
new Dictionary<string, object>
{
{ UsageConstants.Properties.Id, booking.Id },
{ UsageConstants.Properties.TenantId, booking.OrganizationId },
{ UsageConstants.Properties.Started, booking.Start.Value.Hour },
{
UsageConstants.Properties.Duration,
Expand Down Expand Up @@ -117,6 +118,7 @@ public async Task<Result<Booking, Error>> MakeBookingAsync(ICallerContext caller
new Dictionary<string, object>
{
{ UsageConstants.Properties.Id, booking.Id },
{ UsageConstants.Properties.TenantId, booking.OrganizationId },
{ UsageConstants.Properties.Started, booking.Start.Value.Hour },
{
UsageConstants.Properties.Duration,
Expand Down
1 change: 1 addition & 0 deletions src/CarsApplication/CarsApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public async Task<Result<Car, Error>> RegisterCarAsync(ICallerContext caller, st
new Dictionary<string, object>
{
{ UsageConstants.Properties.Id, car.Id },
{ UsageConstants.Properties.TenantId, car.OrganizationId },
{ UsageConstants.Properties.CarMake, car.Manufacturer.Value.Make.Text },
{ UsageConstants.Properties.CarModel, car.Manufacturer.Value.Model.Text },
{ UsageConstants.Properties.CarYear, car.Manufacturer.Value.Year.Number }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public async Task WhenAuthenticateAsyncAndNoCredentials_ThenReturnsError()
await _application.AuthenticateAsync(_caller.Object, "ausername", "apassword", CancellationToken.None);

result.Should().BeError(ErrorCode.NotAuthenticated);
_repository.Verify(rep => rep.SaveAsync(It.IsAny<PasswordCredentialRoot>(), It.IsAny<CancellationToken>()),
Times.Never);
_recorder.Verify(rec => rec.AuditAgainst(It.IsAny<ICallContext>(), It.IsAny<string>(),
It.IsAny<string>(), It.IsAny<string>(), It.IsAny<object[]>()), Times.Never);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static Result<StreamResult, Error> HandleApplicationResult<TResource>(thi

private static IResult ToResult(this StreamResult result, OperationMethod _)
{
return Results.Stream(result.Stream, result.ContentType);
return Results.Stream(result.Stream, result.ContentType, result.FileName);
}

private static IResult ToResult<TResponse>(this PostResult<TResponse> postResult, OperationMethod method)
Expand Down
8 changes: 8 additions & 0 deletions src/Infrastructure.Web.Api.Interfaces/ApiResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ public StreamResult(Stream stream, string contentType)
ContentType = contentType;
}

public StreamResult(Stream stream, string contentType, string fileName)
{
FileName = fileName;
Stream = stream;
ContentType = contentType;
}

public string? FileName { get; }
public string ContentType { get; }

public Stream Stream { get; }
Expand Down
4 changes: 2 additions & 2 deletions src/IntegrationTesting.WebApi.Common/WebApiSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public abstract class WebApiSpec<THost> : IClassFixture<WebApiSetup<THost>>, IDi
{
protected const string PasswordForPerson = "1Password!";
private const string DotNetCommandLineWithLaunchProfileArgumentsFormat =
"run --no-build --configuration {0} --launch-profile {1} --project {2}";
"run --no-build --configuration {0} --launch-profile {1} --project \"{2}\"";
private const string TestingServerUrl = "https://localhost";
private const int WaitStateRetries = 30;
// ReSharper disable once StaticMemberInGenericType
Expand Down Expand Up @@ -284,7 +284,7 @@ protected async Task<LoginDetails> LoginUserAsync(LoginUser who = LoginUser.Pers

/// <summary>
/// Manually propagates domain_events that are queued and waiting to be processed on the message bus.
/// Flows: <see href="https://github.com/jezzsantos/saastack/blob/main/docs/images/Eventing-Flows-Generic.png" />
/// Flows: <see href="../docs/images/Eventing-Flows-Generic.png" />
/// </summary>
protected async Task PropagateDomainEventsAsync(PropagationRounds rounds = PropagationRounds.Once)
{
Expand Down

0 comments on commit 318c497

Please sign in to comment.