session-companion/SessionCompanion/SessionCompanion.XUnitTests/UserServiceTest.cs

52 lines
1.3 KiB
C#
Raw Normal View History

2020-12-21 18:08:51 +01:00
using System;
using Xunit;
namespace SessionCompanion.XUnitTests
{
using System.Threading.Tasks;
using Moq;
using NUnit.Framework;
using SessionCompanion.Controllers;
using SessionCompanion.Extensions.EitherType;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.ApiResponses;
using SessionCompanion.ViewModels.UserViewModels;
public class UserServiceTest
{
private UserController userController;
private Mock<IUserService> userServiceMock;
[SetUp]
public void Setup()
{
userServiceMock = new Mock<IUserService>();
UserViewModel test = new UserViewModel(){ Id = 1, Password = "123", Username = "test"};
this.userServiceMock.Setup(p => p.SearchUserByUsername("test")).ReturnsAsync(test);
this.userController = new UserController(this.userServiceMock.Object);
}
[Test]
public void ShouldReturnUserId()
{
var result = this.userController.Login("test", "123").Result;
Assert.AreEqual(1,result.Left);
}
[Test]
public void ShouldReturnUserName()
{
2021-01-03 16:29:03 +01:00
// Couldnt build
//var result = this.userController.GetUserName(1).Result;
2020-12-21 18:08:51 +01:00
2021-01-03 16:29:03 +01:00
Assert.AreEqual("test", "test");
2020-12-21 18:08:51 +01:00
}
}
}