53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
// Copyright (c) 2020 Tudor Stanciu
|
|
|
|
using System;
|
|
using Tuitio.Application.Stores;
|
|
using Tuitio.Domain.Models;
|
|
using Xunit;
|
|
|
|
namespace Tuitio.Application.Tests
|
|
{
|
|
public class TokenStoreTests
|
|
{
|
|
private TokenExtension GetMockedToken()
|
|
{
|
|
var token = Token.Initialize(1, 0, "test.tuitio", "tuitio", "user", "user.tuitio@lab.com", Guid.NewGuid().ToString(), null);
|
|
var extension = token.Extend(null, null);
|
|
return extension;
|
|
}
|
|
|
|
[Fact]
|
|
public void Set_ShouldSetTokenInStore()
|
|
{
|
|
// Arrange
|
|
var key = "user001";
|
|
var expected = GetMockedToken();
|
|
|
|
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();
|
|
var store = new TokenStore();
|
|
|
|
// Act
|
|
store.Set(key, mock);
|
|
store.Remove(key);
|
|
var actual = store.Get(key);
|
|
|
|
// Assert
|
|
Assert.True(actual == null);
|
|
}
|
|
}
|
|
} |