tuitio/test/UnitTests/Tuitio.Application.Tests/TokenStoreTests.cs

53 lines
1.3 KiB
C#
Raw Normal View History

2023-03-13 18:36:59 +02:00
// Copyright (c) 2020 Tudor Stanciu
using System;
2023-03-13 18:36:59 +02:00
using Tuitio.Application.Stores;
2023-03-09 20:31:17 +02:00
using Tuitio.Domain.Models;
using Xunit;
namespace Tuitio.Application.Tests
{
public class TokenStoreTests
{
private Token GetMockedToken()
{
var token = new Token(1);
token.SetUserData(0, "test.tuitio", "tuitio", "user", "user.tuitio@lab.com", Guid.NewGuid().ToString(), null, null, null);
return token;
}
2023-03-09 20:31:17 +02:00
[Fact]
public void Set_ShouldSetTokenInStore()
{
// Arrange
var key = "user001";
var expected = GetMockedToken();
2023-03-09 20:31:17 +02:00
var store = new TokenStore();
// Act
store.Set(key, expected);
var actual = store.Get(key);
// Assert
Assert.Equal(expected, actual);
}
[Fact]
public void Remove_ShouldRemoveTokenFromStore()
{
// Arrange
var key = "user001";
var mock = GetMockedToken();
2023-03-09 20:31:17 +02:00
var store = new TokenStore();
// Act
store.Set(key, mock);
store.Remove(key);
var actual = store.Get(key);
// Assert
Assert.True(actual == null);
}
}
}