Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pingu2k4 committed Aug 11, 2024
1 parent 556cad6 commit 087477c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PinguApps.Appwrite.Shared/Utils/TokenUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PinguApps.Appwrite.Shared.Utils;
public static class TokenUtils
{
private record SessionToken(
internal record SessionToken(
[property: JsonPropertyName("id")] string Id,
[property: JsonPropertyName("secret")] string Secret
);
Expand Down
25 changes: 25 additions & 0 deletions tests/PinguApps.Appwrite.Shared.Tests/Utils/TokenUtilsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Text.Json;
using PinguApps.Appwrite.Shared.Utils;

namespace PinguApps.Appwrite.Shared.Tests.Utils;
public class TokenUtilsTests
{
[Fact]
public void GetSessionToken_ShouldReturnBase64EncodedString()
{
// Arrange
string userId = "testUser";
string secret = "testSecret";

// Act
string result = TokenUtils.GetSessionToken(userId, secret);

// Assert
Assert.NotNull(result);
var jsonBytes = Convert.FromBase64String(result);
var session = JsonSerializer.Deserialize<TokenUtils.SessionToken>(jsonBytes);
Assert.NotNull(session);
Assert.Equal(userId, session.Id);
Assert.Equal(secret, session.Secret);
}
}

0 comments on commit 087477c

Please sign in to comment.