LocalGovIMS_localgov-ims/src/BusinessLogic.UnitTests/Services/MethodOfPayment/GetMopTests.cs
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System.Diagnostics.CodeAnalysis;
using Type = BusinessLogic.Entities.Mop;

namespace BusinessLogic.UnitTests.Services.MethodOfPayment
{
    [TestClass]
    [ExcludeFromCodeCoverage]
    public class GetMopTests : BaseTest
    {
        private void SetupUnitOfWork()
        {
            MockUnitOfWork.Setup(x => x.Mops.GetMop(It.IsAny<string>()))
                .Returns(new Type());
        }

        private void SetupSecurityContext(bool result)
        {
            MockSecurityContext.Setup(x => x.IsInRole(It.IsAny<string>()))
                .Returns(result);
        }

        [TestMethod]
        public void ReturnsCorrectType()
        {
            // Arrange
            SetupUnitOfWork();
            SetupSecurityContext(true);
            var service = GetService();

            // Act
            var result = service.GetMop("M1");

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(Type));
        }

        [TestMethod]
        public void OnErrorReturnsNull()
        {
            // Arrange
            SetupSecurityContext(true);
            var service = GetService();

            // Act
            var result = service.GetMop("M1");

            // Assert
            Assert.IsNull(result);
        }

        [TestMethod]
        public void IncorrectSecurityReturnsNull()
        {
            // Arrange
            SetupSecurityContext(false);
            var service = GetService();

            // Act
            var result = service.GetMop("M1");

            // Assert
            Assert.IsNull(result);
        }
    }
}
