using Admin.Classes.Models; using Admin.Interfaces.Commands; using Admin.Interfaces.ModelBuilders; using Admin.Models.Payment; using log4net; using Moq; using System; using System.Linq; using System.Reflection; using System.Web.Mvc; using Controller = Admin.Controllers.PaymentController; using Dependencies = Admin.Controllers.PaymentControllerDependencies; namespace Admin.UnitTests.Controllers.Payment { public class TestBase { protected Controller Controller; protected readonly Mock MockLogger = new Mock(); protected readonly Mock> MockIndexViewModelBuilder = new Mock>(); protected readonly Mock> MockAddCommand = new Mock>(); protected readonly Mock> MockRemoveCommand = new Mock>(); protected readonly Mock> MockEmptyBasketCommand = new Mock>(); protected readonly Mock> MockCheckAddressCommand = new Mock>(); protected readonly Mock> MockCreatePaymentsCommand = new Mock>(); protected readonly Mock> MockSetAddressCommand = new Mock>(); protected readonly Mock> MockProcessPaymentCommand = new Mock>(); protected void SetupController() { var dependencies = new Dependencies( MockLogger.Object, MockIndexViewModelBuilder.Object, MockAddCommand.Object, MockRemoveCommand.Object, MockEmptyBasketCommand.Object, MockCheckAddressCommand.Object, MockCreatePaymentsCommand.Object, MockSetAddressCommand.Object, MockProcessPaymentCommand.Object); Controller = new Controller(dependencies); var controllerContext = new Mock(); controllerContext.SetupGet(p => p.HttpContext.Session["PaymentModel"]).Returns(new IndexViewModel()); Controller.ControllerContext = controllerContext.Object; } protected MethodInfo GetMethod(Type attributeType, string name) { return typeof(Controller).GetMethods() .Where(x => x.CustomAttributes.Any(y => y.AttributeType == attributeType)) .Where(x => x.Name == name) .FirstOrDefault(); } } }