55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
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<IFactoidService> mockFactoidService;
|
|
private readonly Mock<IHttpContextAccessor> mockHttpContextAccessor;
|
|
|
|
public FactoidControllerTest()
|
|
{
|
|
mockFactoidService = new Mock<IFactoidService>();
|
|
mockHttpContextAccessor = new Mock<IHttpContextAccessor>();
|
|
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<FactoidResponse>;
|
|
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);
|
|
}
|
|
}
|
|
} |