LocalGovIMS_localgov-ims/src/Admin.UnitTests/Classes/Commands/User/EditCommandTests.cs
using BusinessLogic.Classes.Result;
using BusinessLogic.Interfaces.Services;
using log4net;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System.Diagnostics.CodeAnalysis;
using Command = Admin.Classes.Commands.User.EditCommand;
using CommandResult = Admin.Classes.Commands.CommandResult;
using ViewModel = Admin.Models.User.EditViewModel;

namespace Admin.UnitTests.Classes.Commands.User
{
    [TestClass]
    [ExcludeFromCodeCoverage]
    public class EditCommandTests
    {
        private readonly Mock<ILog> _mockLogger = new Mock<ILog>();
        private readonly Mock<IUserService> _mockUserService = new Mock<IUserService>();

        private ViewModel GenerateViewModel()
        {
            return new ViewModel()
            {
                Disabled = false,
                ExpiryDays = 10,
                LastLogin = null,
                UserId = 0,
                UserName = string.Empty
            };
        }

        [TestMethod]
        public void OnExecuteReturnsCommandResult()
        {
            // Arrange
            var command = new Command(
                _mockLogger.Object,
                _mockUserService.Object);

            // Act
            var result = command.Execute(GenerateViewModel());

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

        [TestMethod]
        public void OnExecuteReturnsCommandResultFromResult()
        {
            // Arrange
            _mockUserService.Setup(x => x.Update(It.IsAny<BusinessLogic.Entities.User>()))
                .Returns(new Result());

            var command = new Command(
                _mockLogger.Object,
                _mockUserService.Object);

            // Act
            var result = command.Execute(GenerateViewModel());

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