using System.Collections.Generic; using LCU.API.Collections.RepoApi.Controllers; using LCU.API.Collections.RepoApi.Models.Responses; using LCU.API.Collections.RepoApi.Services; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Moq; using Xunit; namespace LCU.API.Collections.RepoApiTests.Controllers { public class FactoidControllerTest { private readonly FactoidController controller; private readonly Mock mockFactoidService; private readonly Mock mockHttpContextAccessor; public FactoidControllerTest() { mockFactoidService = new Mock(); mockHttpContextAccessor = new Mock(); controller = new FactoidController(mockHttpContextAccessor.Object, mockFactoidService.Object); } [Fact] public async void Get_All_Factoids_OK() { // act var result = await controller.GetAllFactoids(); Assert.NotNull(result); var okResult = result as OkObjectResult; // assert Assert.NotNull(okResult); Assert.Equal(200, okResult.StatusCode); var factoidResponses = okResult.Value as IReadOnlyCollection; Assert.Equal(10, factoidResponses.Count); } [Fact] public async void Get_Factoid_O4R_OK() { // act var result = await controller.GetAllAccountsO4R(); Assert.NotNull(result); var okResult = result as OkObjectResult; // assert Assert.NotNull(okResult); Assert.Equal(200, okResult.StatusCode); } } }