public void Initialize(string name, string id, string config, params KeyValuePair <Type, object>[] dependencies) { _httpConfig = new HttpConfiguration(); _logger = new Mock <ILogger>().Object; _settings = new SettingsDictionary(); _settings[SecretPrefix + name] = GetConfigValue(id, config); _config = new WebHookReceiverConfig(_settings, _logger); List <KeyValuePair <Type, object> > deps = new List <KeyValuePair <Type, object> >() { new KeyValuePair <Type, object>(typeof(IWebHookReceiverConfig), _config), new KeyValuePair <Type, object>(typeof(SettingsDictionary), _settings) }; deps.AddRange(dependencies); _httpConfig = HttpConfigurationMock.Create(deps); _request = new HttpRequestMessage(); _receiverMock = new WebHookReceiverMock(); _context = new HttpRequestContext { Configuration = _httpConfig }; _request.SetRequestContext(_context); }
public WebHookRegistrationsControllerTests() { _regsMock = new Mock <IWebHookRegistrationsManager>(); _registrarMock = new Mock <IWebHookRegistrar>(); _idValidator = new Mock <IWebHookIdValidator>(); _principal = new ClaimsPrincipal(); var services = new Dictionary <Type, object> { { typeof(IWebHookRegistrationsManager), _regsMock.Object }, { typeof(IWebHookRegistrar), _registrarMock.Object }, { typeof(IWebHookIdValidator), _idValidator.Object }, }; _config = HttpConfigurationMock.Create(services); _config.Routes.Add(WebHookRouteNames.FiltersGetAction, new HttpRoute()); _request = new HttpRequestMessage(HttpMethod.Get, Address); _request.SetConfiguration(_config); var requestContext = new HttpRequestContext() { Configuration = _config, Principal = _principal, Url = new UrlHelper(_request), }; _controllerContext = new HttpControllerContext() { Configuration = _config, Request = _request, RequestContext = requestContext, }; _controller = new WebHookRegistrationsControllerMock(); _controller.Initialize(_controllerContext); }
public virtual void Initialize(string name, string config) { if (ReceiverMock == null) { ReceiverMock = new Mock <T> { CallBase = true }; } Receiver = ReceiverMock.Object; Logger = new Mock <ILogger>().Object; name = name ?? Receiver.Name; Settings = new SettingsDictionary { [SecretPrefix + name] = config, }; ReceiverConfig = new WebHookReceiverConfig(Settings, Logger); HttpConfig = HttpConfigurationMock.Create(new Dictionary <Type, object> { { typeof(IWebHookReceiverConfig), ReceiverConfig }, { typeof(SettingsDictionary), Settings }, }); RequestContext = new HttpRequestContext { Configuration = HttpConfig }; }
public WebHookRegistrationsControllerTests() { IPrincipal principal = new ClaimsPrincipal(); _managerMock = new Mock <IWebHookManager>(); _storeMock = new Mock <MemoryWebHookStore> { CallBase = true }; _userMock = new Mock <IWebHookUser>(); _userMock.Setup(u => u.GetUserIdAsync(principal)) .ReturnsAsync(TestUser); _filterProviderMock = new Mock <IWebHookFilterProvider>(); _filterProviderMock.Setup(p => p.GetFiltersAsync()) .ReturnsAsync(new Collection <WebHookFilter> { new WebHookFilter { Name = FilterName } }); _filterManager = new WebHookFilterManager(new[] { new WildcardWebHookFilterProvider(), _filterProviderMock.Object }); _registrar = new Mock <IWebHookRegistrar>(); var services = new Dictionary <Type, object> { { typeof(IWebHookManager), _managerMock.Object }, { typeof(IWebHookStore), _storeMock.Object }, { typeof(IWebHookUser), _userMock.Object }, { typeof(IWebHookFilterManager), _filterManager }, { typeof(IWebHookRegistrar), _registrar.Object } }; _config = HttpConfigurationMock.Create(services); _config.Routes.Add(WebHookRouteNames.FiltersGetAction, new HttpRoute()); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, Address); request.SetConfiguration(_config); HttpRequestContext requestContext = new HttpRequestContext() { Configuration = _config, Principal = principal, Url = new UrlHelper(request), }; _controllerContext = new HttpControllerContext() { Configuration = _config, Request = new HttpRequestMessage(), RequestContext = requestContext, }; _controller = new WebHookRegistrationsControllerMock(); _controller.Initialize(_controllerContext); }
public WebHookReceiversControllerTests() { _managerMock = new Mock <IWebHookReceiverManager>(); _config = HttpConfigurationMock.Create(new[] { new KeyValuePair <Type, object>(typeof(IWebHookReceiverManager), _managerMock.Object) }); HttpControllerContext controllerContext = new HttpControllerContext() { Configuration = _config, Request = new HttpRequestMessage(), }; _controller = new WebHookReceiversController(); _controller.ControllerContext = controllerContext; }