-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f227a8
commit 948be03
Showing
29 changed files
with
4,367 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/Gameboard.Api.Tests.Integration/Tests/Features/Support/SupportControllerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Gameboard.Api; | ||
using Gameboard.Api.Common; | ||
using Gameboard.Api.Data; | ||
|
||
namespace Gameboard.Api.Tests.Integration; | ||
|
||
public class SupportControllerTests(GameboardTestContext testContext) : IClassFixture<GameboardTestContext> | ||
{ | ||
private readonly GameboardTestContext _testContext = testContext; | ||
|
||
[Theory, GbIntegrationAutoData] | ||
public async Task Ticket_WhenCreatedWithAutoTagTrigger_AutoTags | ||
( | ||
IFixture fixture, | ||
string gameId, | ||
string tag, | ||
string sponsorId, | ||
string userId | ||
) | ||
{ | ||
// given an autotag which triggers on sponsor and a player with that sponsor | ||
await _testContext.WithDataState(state => | ||
{ | ||
state.Add<Data.Game>(fixture, g => | ||
{ | ||
g.Id = gameId; | ||
g.Players = new Data.Player | ||
{ | ||
Id = fixture.Create<string>(), | ||
Sponsor = state.Build<Data.Sponsor>(fixture, s => s.Id = sponsorId), | ||
User = new Data.User { Id = userId, SponsorId = sponsorId } | ||
}.ToCollection(); | ||
}); | ||
state.Add<SupportSettingsAutoTag>(fixture, t => | ||
{ | ||
t.ConditionType = SupportSettingsAutoTagConditionType.SponsorId; | ||
t.ConditionValue = sponsorId; | ||
t.IsEnabled = true; | ||
t.Tag = tag; | ||
}); | ||
}); | ||
|
||
var result = await _testContext | ||
.CreateHttpClientWithAuthRole(UserRoleKey.Support) | ||
.PostAsync("api/ticket", new NewTicket | ||
{ | ||
AssigneeId = userId, | ||
Description = fixture.Create<string>(), | ||
Summary = fixture.Create<string>(), | ||
RequesterId = userId, | ||
|
||
} | ||
.ToJsonBody()) | ||
.DeserializeResponseAs<Ticket>(); | ||
|
||
// TODO: test support for FromForm | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Gameboard.Api.Tests.Shared/Fixtures/SpecimenBuilders/DateTimeOffsetBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Reflection; | ||
using AutoFixture.Kernel; | ||
|
||
namespace Gameboard.Api.Tests.Shared.Fixtures; | ||
|
||
internal class DateTimeOffsetSpecimenBuilder : ISpecimenBuilder | ||
{ | ||
public object Create(object request, ISpecimenContext context) | ||
{ | ||
var argumentType = typeof(object); | ||
|
||
if (request is PropertyInfo pi) | ||
{ | ||
argumentType = pi.PropertyType; | ||
} | ||
|
||
if (request is ParameterInfo rpi) | ||
{ | ||
argumentType = rpi.ParameterType; | ||
} | ||
|
||
if (argumentType == typeof(DateTimeOffset)) | ||
{ | ||
return DateTimeOffset.UtcNow.ToUniversalTime(); | ||
} | ||
|
||
return new NoSpecimen(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.