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

45 lines
1.2 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
{
[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);
}
}
}