Skip to content

Commit

Permalink
Used Alba instead of Ogooreck for Wolverine sample
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Feb 5, 2024
1 parent c4a665f commit fecb5e7
Show file tree
Hide file tree
Showing 22 changed files with 249 additions and 315 deletions.
Original file line number Diff line number Diff line change
@@ -1,38 +1,28 @@
using Alba;
using Helpdesk.Api.Incidents;
using Helpdesk.Api.Incidents.AcknowledgingResolution;
using Helpdesk.Api.Tests.Incidents.Fixtures;
using Xunit;
using static Ogooreck.API.ApiSpecification;

namespace Helpdesk.Api.Tests.Incidents;

public class AcknowledgeResolutionIncidentTests(ApiWithResolvedIncident API):
IClassFixture<ApiWithResolvedIncident>
public class AcknowledgeResolutionIncidentTests(AppFixture fixture): ApiWithResolvedIncident(fixture)
{
[Fact]
[Trait("Category", "Acceptance")]
public Task ResolveCommand_Succeeds() =>
API
.Given()
.When(
POST,
URI($"/api/customers/{API.Incident.CustomerId}/incidents/{API.Incident.Id}/acknowledge"),
BODY(new AcknowledgeResolution(API.Incident.Id)),
HEADERS(IF_MATCH(2))
)
.Then(OK)
public async Task ResolveCommand_Succeeds()
{
await Host.Scenario(x =>
{
x.Post.Json(new AcknowledgeResolution(Incident.Id, Incident.CustomerId, Incident.Version))
.ToUrl($"/api/customers/{Incident.CustomerId}/incidents/{Incident.Id}/acknowledge");

.And()
x.StatusCodeShouldBeOk();
});

.When(GET, URI($"/api/incidents/{API.Incident.Id}"))
.Then(
OK,
RESPONSE_BODY(
API.Incident with
{
Status = IncidentStatus.ResolutionAcknowledgedByCustomer,
Version = 3
}
)
);
await Host.IncidentDetailsShouldBe(Incident with
{
Status = IncidentStatus.ResolutionAcknowledgedByCustomer, Version = 3
});
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
using Alba;
using Helpdesk.Api.Incidents.AssigningAgent;
using Helpdesk.Api.Tests.Incidents.Fixtures;
using Xunit;
using static Ogooreck.API.ApiSpecification;

namespace Helpdesk.Api.Tests.Incidents;

public class AssignAgentToIncidentTests(ApiWithLoggedIncident API):
IClassFixture<ApiWithLoggedIncident>
public class AssignAgentToIncidentTests(AppFixture fixture): ApiWithLoggedIncident(fixture)
{
[Fact]
[Trait("Category", "Acceptance")]
public async Task AssignAgentCommand_ChangesIncidentCategory()
{
await API
.Given()
.When(
POST,
URI($"/api/agents/{agentId}/incidents/{API.Incident.Id}/assign"),
HEADERS(IF_MATCH(1)),
BODY(new AssignAgentToIncident(API.Incident.Id))
)
.Then(OK)
.And()
.When(GET, URI($"/api/incidents/{API.Incident.Id}"))
.Then(
OK,
RESPONSE_BODY(
API.Incident with { AgentId = agentId, Version = 2 }
)
);
await Host.Scenario(x =>
{
x.Post.Json(new AssignAgentToIncident(Incident.Id, Incident.Version))
.ToUrl($"/api/agents/{agentId}/incidents/{Incident.Id}/assign");

x.StatusCodeShouldBeOk();
});

await Host.IncidentDetailsShouldBe(Incident with { AgentId = agentId, Version = 2 });
}

private readonly Guid agentId = Guid.NewGuid();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
using Alba;
using Bogus;
using Helpdesk.Api.Incidents;
using Helpdesk.Api.Incidents.Categorising;
using Helpdesk.Api.Tests.Incidents.Fixtures;
using Xunit;
using static Ogooreck.API.ApiSpecification;

namespace Helpdesk.Api.Tests.Incidents;

public class CategoriseIncidentTests(ApiWithLoggedIncident API):
IClassFixture<ApiWithLoggedIncident>
public class CategoriseIncidentTests(AppFixture fixture): ApiWithLoggedIncident(fixture)
{
[Fact]
[Trait("Category", "Acceptance")]
public async Task CategoriseCommand_ChangesIncidentCategory()
{
await API
.Given()
.When(
POST,
URI($"/api/agents/{agentId}/incidents/{API.Incident.Id}/category"),
BODY(new CategoriseIncident(API.Incident.Id, category)),
HEADERS(IF_MATCH(1))
)
.Then(OK);
await Host.Scenario(x =>
{
x.Post.Json(new CategoriseIncident(Incident.Id, category, Incident.Version))
.ToUrl($"/api/agents/{agentId}/incidents/{Incident.Id}/category");

await API
.Given()
.When(GET, URI($"/api/incidents/{API.Incident.Id}"))
.Then(
OK,
RESPONSE_BODY(
API.Incident with { Category = category, Version = 2 }
)
);
x.StatusCodeShouldBeOk();
});

await Host.IncidentDetailsShouldBe(Incident with { Category = category, Version = 2 });
}

private readonly Guid agentId = Guid.NewGuid();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
using Alba;
using Helpdesk.Api.Incidents;
using Helpdesk.Api.Incidents.Closing;
using Helpdesk.Api.Tests.Incidents.Fixtures;
using Xunit;
using static Ogooreck.API.ApiSpecification;

namespace Helpdesk.Api.Tests.Incidents;

public class CloseIncidentTests(ApiWithAcknowledgedIncident API):
IClassFixture<ApiWithAcknowledgedIncident>
public class CloseIncidentTests(AppFixture fixture): ApiWithAcknowledgedIncident(fixture)
{
[Fact]
[Trait("Category", "Acceptance")]
public async Task ResolveCommand_Succeeds()
{
await API
.Given()
.When(
POST,
URI($"/api/agents/{agentId}/incidents/{API.Incident.Id}/close"),
BODY(new CloseIncident(API.Incident.Id)),
HEADERS(IF_MATCH(3))
)
.Then(OK);
await Host.Scenario(x =>
{
x.Post.Json(new CloseIncident(Incident.Id, Incident.Version))
.ToUrl($"/api/agents/{agentId}/incidents/{Incident.Id}/close");

await API
.Given()
.When(GET, URI($"/api/incidents/{API.Incident.Id}"))
.Then(
OK,
RESPONSE_BODY(
API.Incident with { Status = IncidentStatus.Closed, Version = 4 }
)
);
x.StatusCodeShouldBeOk();
});

await Host.IncidentDetailsShouldBe(Incident with { Status = IncidentStatus.Closed, Version = 4 });
}

private Guid agentId = Guid.NewGuid();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
using Helpdesk.Api.Incidents.GettingDetails;
using Ogooreck.API;
using Xunit;

namespace Helpdesk.Api.Tests.Incidents.Fixtures;

public class ApiWithAcknowledgedIncident: ApiSpecification<Program>, IAsyncLifetime
public class ApiWithAcknowledgedIncident(AppFixture fixture): IntegrationContext(fixture), IAsyncLifetime
{
public async Task InitializeAsync()
{
Incident = await this.AcknowledgedIncident();
}
public override async Task InitializeAsync() =>
Incident = await Host.AcknowledgedIncident();

public IncidentDetails Incident { get; set; } = default!;

public Task DisposeAsync() => Task.CompletedTask;
}

Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using Helpdesk.Api.Incidents.GettingDetails;
using Ogooreck.API;
using Xunit;

namespace Helpdesk.Api.Tests.Incidents.Fixtures;

public class ApiWithLoggedIncident: ApiSpecification<Program>, IAsyncLifetime
public class ApiWithLoggedIncident(AppFixture fixture): IntegrationContext(fixture), IAsyncLifetime
{
public async Task InitializeAsync()
{
Incident = await this.LoggedIncident();
}
public override async Task InitializeAsync() =>
Incident = await Host.LoggedIncident();

public IncidentDetails Incident { get; protected set; } = default!;
public Task DisposeAsync() => Task.CompletedTask;
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
using Helpdesk.Api.Incidents.GettingDetails;
using Ogooreck.API;
using Xunit;

namespace Helpdesk.Api.Tests.Incidents.Fixtures;

public class ApiWithResolvedIncident: ApiSpecification<Program>, IAsyncLifetime
public class ApiWithResolvedIncident(AppFixture fixture): IntegrationContext(fixture), IAsyncLifetime
{
public async Task InitializeAsync()
{
Incident = await this.ResolvedIncident();
}
public override async Task InitializeAsync() =>
Incident = await Host.ResolvedIncident();

public IncidentDetails Incident { get; set; } = default!;

public Task DisposeAsync() => Task.CompletedTask;
}

Loading

0 comments on commit fecb5e7

Please sign in to comment.