-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tweak evt reward logic and add more tests
- Loading branch information
Showing
6 changed files
with
258 additions
and
29 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
DragaliaAPI.Integration.Test/Features/Event/Clb01EventTest.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,69 @@ | ||
using DragaliaAPI.Database.Entities; | ||
using DragaliaAPI.Models; | ||
using DragaliaAPI.Models.Generated; | ||
using DragaliaAPI.Shared.Definitions.Enums.EventItemTypes; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace DragaliaAPI.Integration.Test.Features.Event; | ||
|
||
public class Clb01EventTest : TestFixture | ||
{ | ||
public Clb01EventTest( | ||
CustomWebApplicationFactory<Program> factory, | ||
ITestOutputHelper outputHelper | ||
) | ||
: base(factory, outputHelper) { } | ||
|
||
private const int EventId = 21401; | ||
private const string Prefix = "clb01_event"; | ||
|
||
[Fact] | ||
public async Task GetEventData_ReturnsEventData() | ||
{ | ||
await Client.PostMsgpack<MemoryEventActivateData>( | ||
"memory_event/activate", | ||
new MemoryEventActivateRequest(EventId) | ||
); | ||
|
||
DragaliaResponse<Clb01EventGetEventDataData> evtData = | ||
await Client.PostMsgpack<Clb01EventGetEventDataData>( | ||
$"{Prefix}/get_event_data", | ||
new Clb01EventGetEventDataRequest(EventId) | ||
); | ||
|
||
evtData.data.clb_01_event_user_data.Should().NotBeNull(); | ||
evtData.data.clb_01_event_reward_list.Should().NotBeNull(); | ||
} | ||
|
||
[Fact] | ||
public async Task ReceiveEventRewards_ReturnsEventRewards() | ||
{ | ||
await Client.PostMsgpack<MemoryEventActivateData>( | ||
"memory_event/activate", | ||
new MemoryEventActivateRequest(EventId) | ||
); | ||
|
||
DbPlayerEventItem pointItem = await ApiContext.PlayerEventItems.SingleAsync( | ||
x => x.EventId == EventId && x.Type == (int)Clb01EventItemType.Clb01EventPoint | ||
); | ||
|
||
pointItem.Quantity += 500; | ||
|
||
ApiContext.PlayerEventRewards.RemoveRange( | ||
ApiContext.PlayerEventRewards.Where(x => x.EventId == EventId) | ||
); | ||
|
||
await ApiContext.SaveChangesAsync(); | ||
|
||
DragaliaResponse<Clb01EventReceiveClb01PointRewardData> evtResp = | ||
await Client.PostMsgpack<Clb01EventReceiveClb01PointRewardData>( | ||
$"{Prefix}/receive_clb01_point_reward", | ||
new Clb01EventReceiveClb01PointRewardRequest(EventId) | ||
); | ||
|
||
evtResp.data.clb_01_event_reward_entity_list.Should().NotBeNullOrEmpty(); | ||
evtResp.data.clb_01_event_reward_list.Should().NotBeNullOrEmpty(); | ||
evtResp.data.entity_result.Should().NotBeNull(); | ||
evtResp.data.update_data_list.Should().NotBeNull(); | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
DragaliaAPI.Integration.Test/Features/Event/CombatEventTest.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,111 @@ | ||
using DragaliaAPI.Database.Entities; | ||
using DragaliaAPI.Models; | ||
using DragaliaAPI.Models.Generated; | ||
using DragaliaAPI.Shared.Definitions.Enums.EventItemTypes; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace DragaliaAPI.Integration.Test.Features.Event; | ||
|
||
public class CombatEventTest : TestFixture | ||
{ | ||
public CombatEventTest( | ||
CustomWebApplicationFactory<Program> factory, | ||
ITestOutputHelper outputHelper | ||
) | ||
: base(factory, outputHelper) { } | ||
|
||
private const int EventId = 22213; | ||
private const string Prefix = "combat_event"; | ||
|
||
[Fact] | ||
public async Task GetEventData_ReturnsEventData() | ||
{ | ||
await Client.PostMsgpack<MemoryEventActivateData>( | ||
"memory_event/activate", | ||
new MemoryEventActivateRequest(EventId) | ||
); | ||
|
||
DragaliaResponse<CombatEventGetEventDataData> evtData = | ||
await Client.PostMsgpack<CombatEventGetEventDataData>( | ||
$"{Prefix}/get_event_data", | ||
new CombatEventGetEventDataRequest(EventId) | ||
); | ||
|
||
evtData.data.combat_event_user_data.Should().NotBeNull(); | ||
evtData.data.user_event_location_reward_list.Should().NotBeNull(); | ||
evtData.data.event_reward_list.Should().NotBeNull(); | ||
evtData.data.event_trade_list.Should().NotBeNull(); | ||
} | ||
|
||
[Fact] | ||
public async Task ReceiveEventRewards_ReturnsEventRewards() | ||
{ | ||
await Client.PostMsgpack<MemoryEventActivateData>( | ||
"memory_event/activate", | ||
new MemoryEventActivateRequest(EventId) | ||
); | ||
|
||
DbPlayerEventItem pointItem = await ApiContext.PlayerEventItems.SingleAsync( | ||
x => x.EventId == EventId && x.Type == (int)Clb01EventItemType.Clb01EventPoint | ||
); | ||
|
||
pointItem.Quantity += 500; | ||
|
||
ApiContext.PlayerEventRewards.RemoveRange( | ||
ApiContext.PlayerEventRewards.Where(x => x.EventId == EventId) | ||
); | ||
|
||
await ApiContext.SaveChangesAsync(); | ||
|
||
DragaliaResponse<CombatEventReceiveEventPointRewardData> evtResp = | ||
await Client.PostMsgpack<CombatEventReceiveEventPointRewardData>( | ||
$"{Prefix}/receive_event_point_reward", | ||
new CombatEventReceiveEventPointRewardRequest(EventId) | ||
); | ||
|
||
evtResp.data.event_reward_entity_list.Should().NotBeNullOrEmpty(); | ||
evtResp.data.event_reward_list.Should().NotBeNullOrEmpty(); | ||
evtResp.data.entity_result.Should().NotBeNull(); | ||
evtResp.data.update_data_list.Should().NotBeNull(); | ||
} | ||
|
||
[Fact] | ||
public async Task ReceiveEventLocationRewards_ReturnsEventLocationRewards() | ||
{ | ||
await Client.PostMsgpack<MemoryEventActivateData>( | ||
"memory_event/activate", | ||
new MemoryEventActivateRequest(EventId) | ||
); | ||
|
||
DbPlayerEventItem pointItem = await ApiContext.PlayerEventItems.SingleAsync( | ||
x => x.EventId == EventId && x.Type == (int)Clb01EventItemType.Clb01EventPoint | ||
); | ||
|
||
pointItem.Quantity += 500; | ||
|
||
ApiContext.PlayerQuests.RemoveRange( | ||
ApiContext.PlayerQuests.Where(x => x.DeviceAccountId == DeviceAccountId) | ||
); | ||
|
||
ApiContext.PlayerQuests.Add( | ||
new DbQuest | ||
{ | ||
DeviceAccountId = DeviceAccountId, | ||
QuestId = 222130103, | ||
State = 3 | ||
} | ||
); | ||
|
||
await ApiContext.SaveChangesAsync(); | ||
|
||
DragaliaResponse<CombatEventReceiveEventLocationRewardData> evtResp = | ||
await Client.PostMsgpack<CombatEventReceiveEventLocationRewardData>( | ||
$"{Prefix}/receive_event_location_reward", | ||
new CombatEventReceiveEventLocationRewardRequest(EventId, 2221302) | ||
); | ||
|
||
evtResp.data.event_location_reward_entity_list.Should().NotBeNullOrEmpty(); | ||
evtResp.data.user_event_location_reward_list.Should().NotBeNullOrEmpty(); | ||
evtResp.data.update_data_list.Should().NotBeNull(); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
DragaliaAPI.Integration.Test/Features/Event/RaidEventTest.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,68 @@ | ||
using DragaliaAPI.Database.Entities; | ||
using DragaliaAPI.Models; | ||
using DragaliaAPI.Models.Generated; | ||
using DragaliaAPI.Shared.Definitions.Enums.EventItemTypes; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace DragaliaAPI.Integration.Test.Features.Event; | ||
|
||
public class RaidEventTest : TestFixture | ||
{ | ||
public RaidEventTest( | ||
CustomWebApplicationFactory<Program> factory, | ||
ITestOutputHelper outputHelper | ||
) | ||
: base(factory, outputHelper) { } | ||
|
||
private const int EventId = 20455; | ||
private const string Prefix = "raid_event"; | ||
|
||
[Fact] | ||
public async Task GetEventData_ReturnsEventData() | ||
{ | ||
await Client.PostMsgpack<MemoryEventActivateData>( | ||
"memory_event/activate", | ||
new MemoryEventActivateRequest(EventId) | ||
); | ||
|
||
DragaliaResponse<RaidEventGetEventDataData> evtData = | ||
await Client.PostMsgpack<RaidEventGetEventDataData>( | ||
$"{Prefix}/get_event_data", | ||
new RaidEventGetEventDataRequest(EventId) | ||
); | ||
|
||
evtData.data.raid_event_user_data.Should().NotBeNull(); | ||
evtData.data.raid_event_reward_list.Should().NotBeNull(); | ||
} | ||
|
||
[Fact] | ||
public async Task ReceiveEventRewards_ReturnsEventRewards() | ||
{ | ||
await Client.PostMsgpack<MemoryEventActivateData>( | ||
"memory_event/activate", | ||
new MemoryEventActivateRequest(EventId) | ||
); | ||
|
||
DbPlayerEventItem pointItem = await ApiContext.PlayerEventItems.SingleAsync( | ||
x => x.EventId == EventId && x.Type == (int)RaidEventItemType.RaidPoint1 | ||
); | ||
|
||
pointItem.Quantity += 500; | ||
|
||
ApiContext.PlayerEventRewards.RemoveRange( | ||
ApiContext.PlayerEventRewards.Where(x => x.EventId == EventId) | ||
); | ||
|
||
await ApiContext.SaveChangesAsync(); | ||
|
||
DragaliaResponse<RaidEventReceiveRaidPointRewardData> evtResp = | ||
await Client.PostMsgpack<RaidEventReceiveRaidPointRewardData>( | ||
$"{Prefix}/receive_clb01_point_reward", | ||
new RaidEventReceiveRaidPointRewardRequest(EventId, new[] { 1001 }) | ||
); | ||
|
||
evtResp.data.raid_event_reward_list.Should().NotBeNullOrEmpty(); | ||
evtResp.data.entity_result.Should().NotBeNull(); | ||
evtResp.data.update_data_list.Should().NotBeNull(); | ||
} | ||
} |
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