Skip to content

Commit f682a58

Browse files
committed
Fix UploadPhoto() calls in tests, return GamePhoto with UploadPhoto()
1 parent 974f659 commit f682a58

3 files changed

Lines changed: 20 additions & 15 deletions

File tree

Refresh.Database/GameDatabaseContext.Photos.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public partial class GameDatabaseContext // Photos
2828
.Include(p => p.Subject4User)
2929
.Include(p => p.Subject4User!.Statistics);
3030

31-
public void UploadPhoto(IPhotoUpload photo, IEnumerable<IPhotoUploadSubject> subjects, GameUser publisher, GameLevel? level)
31+
public GamePhoto UploadPhoto(IPhotoUpload photo, IEnumerable<IPhotoUploadSubject> subjects, GameUser publisher, GameLevel? level)
3232
{
3333
GamePhoto newPhoto = new()
3434
{
@@ -39,7 +39,7 @@ public void UploadPhoto(IPhotoUpload photo, IEnumerable<IPhotoUploadSubject> sub
3939

4040
Publisher = publisher,
4141
Level = level,
42-
LevelType = photo.LevelSlotType,
42+
LevelType = photo.LevelType,
4343
OriginalLevelId = photo.LevelId,
4444
OriginalLevelName = photo.LevelTitle,
4545

@@ -91,6 +91,7 @@ public void UploadPhoto(IPhotoUpload photo, IEnumerable<IPhotoUploadSubject> sub
9191
}
9292

9393
this.CreatePhotoUploadEvent(publisher, newPhoto);
94+
return newPhoto;
9495
}
9596

9697
public void RemovePhoto(GamePhoto photo)

RefreshTests.GameServer/TestContext.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Refresh.Interfaces.Game.Endpoints.DataTypes.Request;
1717
using Refresh.Database.Models.Playlists;
1818
using Refresh.Interfaces.APIv3.Endpoints.DataTypes.Request;
19+
using Refresh.Database.Models.Photos;
1920

2021
namespace RefreshTests.GameServer;
2122

@@ -144,7 +145,7 @@ public GameLevel CreateLevel(GameUser author, string title, string description,
144145
return level;
145146
}
146147

147-
public void CreatePhotoWithSubject(GameUser author, string imageHash)
148+
public GamePhoto CreatePhotoWithSubject(GameUser author, string imageHash, GameLevel? level = null)
148149
{
149150
// TODO: Return newly created GamePhoto
150151
if (this.Database.GetAssetFromHash(imageHash) == null)
@@ -155,22 +156,25 @@ public void CreatePhotoWithSubject(GameUser author, string imageHash)
155156
});
156157
}
157158

158-
this.Database.UploadPhoto(new()
159+
SerializedPhoto photo = new()
159160
{
160161
AuthorName = author.Username,
161162
SmallHash = imageHash,
162163
MediumHash = imageHash,
163164
LargeHash = imageHash,
164-
PhotoSubjects =
165-
[
166-
new()
167-
{
168-
Username = author.Username,
169-
DisplayName = author.Username,
170-
BoundsList = "10,10,10,10"
171-
}
172-
]
173-
}, author);
165+
166+
};
167+
IEnumerable<SerializedPhotoSubject> subjects =
168+
[
169+
new()
170+
{
171+
Username = author.Username,
172+
DisplayName = author.Username,
173+
BoundsList = "10,10,10,10"
174+
}
175+
];
176+
177+
return this.Database.UploadPhoto(photo, subjects, author, level);
174178
}
175179

176180
public void FillLeaderboard(GameLevel level, int count, byte type)

RefreshTests.GameServer/Tests/Levels/LevelDeletionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void DeletesLevelWithPhotos()
7373
],
7474
};
7575

76-
context.Database.UploadPhoto(photo, author);
76+
context.Database.UploadPhoto(photo, photo.PhotoSubjects, author, level);
7777
context.Database.Refresh();
7878

7979
level = context.Database.GetLevelById(level.LevelId);

0 commit comments

Comments
 (0)