public override object CreateController(ControllerContext context) { var controller = (ControllerBase)base.CreateController(context); DotNetCoreServiceLocator.Initial(new HttpContextServiceLocator(_httpContextAccessor)); return(controller); }
private void SetupServiceLocator() { var eventBus = new Mock <IEventBus>(); var container = new Mock <IDotNetCoreServiceLocator>(); container.Setup(s => s.Resolve <IEventBus>()).Returns(() => eventBus.Object); var alterationServiceValidator = new Mock <IValidateAlterationService>(); var Alteration = new Alteration(); alterationServiceValidator.Setup(validator => validator.HasAlteredBefore(Alteration)).Returns(false); alterationServiceValidator.Setup(validator => validator.IsAlterationMeasuresValid(Alteration)).Returns(true); container.Setup(s => s.Resolve <IValidateAlterationService>()).Returns(() => alterationServiceValidator.Object); DotNetCoreServiceLocator.Initial(container.Object); }