using System.Collections.Generic; using System.Threading.Tasks; using LCU.API.Internal.Operations.IncentiveApi.Services; using LCU.Library.Internal.IncentiveApiModels.Entities; using Microsoft.AspNetCore.Mvc; using Moq; using NUnit.Framework; using LCU.API.Internal.Operations.IncentiveApi.Controllers; using LCU.API.Internal.Operations.IncentiveApiLib.Persistence; using LCU.API.Internal.Operations.IncentiveApiLib.Services; namespace Application.UnitTests.Controllers { public class SettingsControllerTest { private SettingsController _controller; private Mock _mockCurrentUserService; private Mock _mockDepartmentService; private Mock _mockSettingsService; private Mock _mockUserService; [SetUp] public void Setup() { _mockCurrentUserService = new Mock(); _mockDepartmentService = new Mock(); _mockSettingsService = new Mock(); _mockUserService = new Mock(); _controller = new SettingsController( _mockCurrentUserService.Object, new DateTimeService(), _mockDepartmentService.Object, _mockSettingsService.Object, _mockUserService.Object ); } [Test] public async Task Get_OK() { _mockDepartmentService.Setup(service => service.GetAllDepartmentsAsync()).ReturnsAsync( new List() { new Department() { Id = 0 } }); _mockUserService.Setup(service => service.GetAllUserSummariesAsync()).ReturnsAsync( new List() { new UserSummary() { } }); var result = await _controller.Get(); Assert.NotNull(result); var okResult = result as OkObjectResult; Assert.NotNull(okResult); Assert.AreEqual(200, okResult.StatusCode); } } }