44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
// Copyright (c) 2020 Tudor Stanciu
|
|
|
|
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);
|
|
}
|
|
}
|
|
} |