42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
|
using Tuitio.Application.Stores;
|
|||
|
using Tuitio.Domain.Models;
|
|||
|
using Xunit;
|
|||
|
|
|||
|
namespace Tuitio.Application.Tests
|
|||
|
{
|
|||
|
public class TokenStoreTests
|
|||
|
{
|
|||
|
[Fact]
|
|||
|
public void Set_ShouldSetTokenInStore()
|
|||
|
{
|
|||
|
// Arrange
|
|||
|
var key = "user001";
|
|||
|
var expected = new Token() { TokenId = Guid.NewGuid(), UserId = 0, UserName = "test.tuitio", CreatedAt = DateTime.Now };
|
|||
|
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 = new Token() { TokenId = Guid.NewGuid(), UserId = 0, UserName = "test.tuitio", CreatedAt = DateTime.Now };
|
|||
|
var store = new TokenStore();
|
|||
|
|
|||
|
// Act
|
|||
|
store.Set(key, mock);
|
|||
|
store.Remove(key);
|
|||
|
var actual = store.Get(key);
|
|||
|
|
|||
|
// Assert
|
|||
|
Assert.True(actual == null);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|