68 lines
2.6 KiB
C#
68 lines
2.6 KiB
C#
using LCU.API.Internal.CoreSoapApiWrapper.Controllers;
|
|
using LCU.API.Internal.CoreSoapApiWrapper.CoreSoapUtilities;
|
|
using LCU.API.Internal.CoreSoapApiWrapper.Services;
|
|
using Moq;
|
|
using System.Web.Http.Results;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System;
|
|
using LCU.API.Internal.CoreSoapApiWrapper.Models.Requests;
|
|
using System.Collections.Generic;
|
|
|
|
namespace LCU.API.Internal.CoreSoapApiWrapperTest.Controllers
|
|
{
|
|
[TestClass]
|
|
public class PersonAgreementControllerTest
|
|
{
|
|
private PersonAgreementController _controller;
|
|
private Mock<IPersonAgreementService> _mockPersonAgreementService;
|
|
|
|
public PersonAgreementControllerTest()
|
|
{
|
|
_mockPersonAgreementService = new Mock<IPersonAgreementService>();
|
|
_controller = new PersonAgreementController(_mockPersonAgreementService.Object);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void PutPersonAgreementsDetailTypes_Null_BadRequest()
|
|
{
|
|
|
|
_mockPersonAgreementService.Verify(x => x.UpdatePersonAgreementsDetailTypes(
|
|
It.IsAny<PersonAgreementDetailTypeRequest>()), Times.Never);
|
|
|
|
var result = _controller.PutPersonAgreementsDetailTypes(null);
|
|
|
|
Assert.IsNotNull(result);
|
|
var okResult = result as BadRequestErrorMessageResult;
|
|
Assert.IsNotNull(okResult);
|
|
_mockPersonAgreementService.Verify(x => x.UpdatePersonAgreementsDetailTypes(
|
|
It.IsAny<PersonAgreementDetailTypeRequest>()), Times.Never);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void PutPersonAgreementsDetailTypes_Exception()
|
|
{
|
|
var request = new PersonAgreementDetailTypeRequest()
|
|
{
|
|
PersonNumber = 1,
|
|
AgreeNumber = 2,
|
|
DetailTypes = new List<DetailType>()
|
|
{
|
|
new DetailType()
|
|
{
|
|
DetailTypeCode = "Stat",
|
|
DetailValue = "CLOS"
|
|
}
|
|
}
|
|
};
|
|
|
|
_mockPersonAgreementService.Setup(x => x.UpdatePersonAgreementsDetailTypes(request))
|
|
.Throws(new Exception("Error thrown in unit test.")).Verifiable();
|
|
|
|
var result = _controller.PutPersonAgreementsDetailTypes(request);
|
|
Assert.IsNotNull(result);
|
|
var okResult = result as BadRequestErrorMessageResult;
|
|
Assert.IsNotNull(okResult);
|
|
_mockPersonAgreementService.Verify();
|
|
}
|
|
}
|
|
} |