39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Moq;
|
|
using Xunit;
|
|
using LCU.Api.Internal.MaidBotApi.Services;
|
|
using LCU.Api.Internal.MaidBotLib.Models;
|
|
using LCU.API.Internal.MaidBotApi.Controllers;
|
|
namespace LCU.Api.Internal.MaidBotTests.ControllerTests;
|
|
|
|
public class QueueEventLogControllerTest
|
|
{
|
|
private readonly QueueEventLogController _queueEventLogController;
|
|
private readonly Mock<IQueueEventLogService> _mockQueueEventLogService;
|
|
|
|
public QueueEventLogControllerTest()
|
|
{
|
|
_mockQueueEventLogService = new Mock<IQueueEventLogService>();
|
|
_queueEventLogController = new QueueEventLogController(_mockQueueEventLogService.Object);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task PostLoggingMatrix_throwsException_500()
|
|
{
|
|
var eventLog = new EventLog() { };
|
|
_mockQueueEventLogService.Setup(service => service.QueueEventLog(eventLog)).Throws(new Exception("Exception from unit test"));
|
|
|
|
// Act
|
|
var result = await _queueEventLogController.Post(eventLog);
|
|
|
|
// Assert
|
|
Assert.NotNull(result);
|
|
|
|
var okResult = result as StatusCodeResult;
|
|
Assert.NotNull(okResult);
|
|
Assert.Equal(StatusCodes.Status500InternalServerError, okResult.StatusCode);
|
|
}
|
|
} |