Skip to content

Commit

Permalink
Add unit tests for missing fields and classes
Browse files Browse the repository at this point in the history
  • Loading branch information
vicr123 committed Dec 8, 2024
1 parent e226d8f commit 752f827
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Backend/Remora.Discord.API/API/Objects/Messages/MessageSnapshot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// MessageSnapshot.cs
//
// Author:
// Jarl Gullberg <[email protected]>
//
// Copyright (c) Jarl Gullberg
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

using JetBrains.Annotations;
using Remora.Discord.API.Abstractions.Objects;

namespace Remora.Discord.API.Objects;

/// <inheritdoc cref="IMessageSnapshot" />
[PublicAPI]
public record MessageSnapshot(IPartialMessage Message) : IMessageSnapshot;
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ private static JsonSerializerOptions AddMessageObjectConverters(this JsonSeriali

options.AddDataObjectConverter<IMessageActivity, MessageActivity>();
options.AddDataObjectConverter<IMessageReference, MessageReference>();
options.AddDataObjectConverter<IMessageSnapshot, MessageSnapshot>();

return options;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// MessageSnapshotTests.cs
//
// Author:
// Jarl Gullberg <[email protected]>
//
// Copyright (c) Jarl Gullberg
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

using Remora.Discord.API.Abstractions.Objects;
using Remora.Discord.API.Tests.TestBases;

namespace Remora.Discord.API.Tests.Objects;

/// <inheritdoc />
public class MessageSnapshotTests : ObjectTestBase<IMessageSnapshot>
{
/// <summary>
/// Initializes a new instance of the <see cref="MessageSnapshotTests"/> class.
/// </summary>
/// <param name="fixture">The test fixture.</param>
public MessageSnapshotTests(JsonBackedTypeTestFixture fixture)
: base(fixture)
{
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"type": 0,
"message_id": "999999999999999999",
"channel_id": "999999999999999999",
"guild_id": "999999999999999999",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"message": {
"content": "none",
"timestamp": "1970-01-01T00:00:00.000000+00:00",
"edited_timestamp": "1970-01-01T00:00:00.000000+00:00",
"mentions": [
{
"username": "none",
"discriminator": "9999",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
],
"mention_roles": [
"999999999999999999"
],
"attachments": [
{
"id": "999999999999999999",
"filename": "file.png",
"size": 0,
"url": "https://www.example.org",
"proxy_url": "https://www.example.org"
}
],
"embeds": [
{}
],
"type": 1,
"flags": 1,
"components": [
{
"type": 1,
"components": []
}
],
"sticker_items": [
{
"id": "999999999999999999",
"name": "none",
"format_type": 1
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"message": {
"content": "none",
"timestamp": "1970-01-01T00:00:00.000000+00:00",
"edited_timestamp": "1970-01-01T00:00:00.000000+00:00",
"mentions": [
{
"username": "none",
"discriminator": "9999",
"id": "999999999999999999",
"avatar": "68b329da9893e34099c7d8ad5cb9c940"
}
],
"mention_roles": [
"999999999999999999"
],
"attachments": [
{
"id": "999999999999999999",
"filename": "file.png",
"size": 0,
"url": "https://www.example.org",
"proxy_url": "https://www.example.org"
}
],
"embeds": [
{}
],
"type": 1,
"flags": 1,
"components": [
{
"type": 1,
"components": []
}
],
"sticker_items": [
{
"id": "999999999999999999",
"name": "none",
"format_type": 1
}
]
}
}

0 comments on commit 752f827

Please sign in to comment.