public void Should_enable_features_in_defaults() { var defaultsOrder = new List <Feature>(); var activatedOrder = new List <Feature>(); var level1 = new Activate1 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var level2 = new Activate2 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var level3 = new Activate3 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var settings = new SettingsHolder(); var featureSettings = new FeatureActivator(settings); //the orders matter here to expose a bug featureSettings.Add(level3); featureSettings.Add(level2); featureSettings.Add(level1); featureSettings.SetupFeatures(new FeatureConfigurationContext(null)); Assert.True(level1.IsActive, "Activate1 wasn't activated"); Assert.True(level2.IsActive, "Activate2 wasn't activated"); Assert.True(level3.IsActive, "Activate3 wasn't activated"); Assert.IsInstanceOf <Activate1>(defaultsOrder[0], "Upstream deps should be activated first"); Assert.IsInstanceOf <Activate2>(defaultsOrder[1], "Upstream deps should be activated first"); Assert.IsInstanceOf <Activate3>(defaultsOrder[2], "Upstream deps should be activated first"); CollectionAssert.AreEqual(defaultsOrder, activatedOrder); }
public void Should_enable_features_in_defaults() { var defaultsOrder = new List<Feature>(); var activatedOrder = new List<Feature>(); var level1 = new Activate1 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var level2 = new Activate2 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var level3 = new Activate3 { OnActivation = f => activatedOrder.Add(f), OnDefaults = f => defaultsOrder.Add(f) }; var settings = new SettingsHolder(); var featureSettings = new FeatureActivator(settings); //the orders matter here to expose a bug featureSettings.Add(level3); featureSettings.Add(level2); featureSettings.Add(level1); featureSettings.SetupFeatures(new FeatureConfigurationContext(null)); Assert.True(level1.IsActive, "Activate1 wasn't activated"); Assert.True(level2.IsActive, "Activate2 wasn't activated"); Assert.True(level3.IsActive, "Activate3 wasn't activated"); Assert.IsInstanceOf<Activate1>(defaultsOrder[0], "Upstream deps should be activated first"); Assert.IsInstanceOf<Activate2>(defaultsOrder[1], "Upstream deps should be activated first"); Assert.IsInstanceOf<Activate3>(defaultsOrder[2], "Upstream deps should be activated first"); CollectionAssert.AreEqual(defaultsOrder, activatedOrder); }
/// <summary> /// Activate a Theme Actives a store *Theme*. This returns a 204 response upon success. /// </summary> /// <exception cref="Themes.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body">Request parameters.</param> /// <param name="accept"></param> /// <param name="contentType"></param> /// <returns>Task of ApiResponse (NoContent)</returns> public async System.Threading.Tasks.Task <ApiResponse <NoContent> > ActivateStoreThemeAsyncWithHttpInfo(Activate1 body, string accept, string contentType) { // verify the required parameter 'body' is set if (body == null) { throw new ApiException(400, "Missing required parameter 'body' when calling ThemeActionsApi->ActivateStoreTheme"); } // verify the required parameter 'accept' is set if (accept == null) { throw new ApiException(400, "Missing required parameter 'accept' when calling ThemeActionsApi->ActivateStoreTheme"); } // verify the required parameter 'contentType' is set if (contentType == null) { throw new ApiException(400, "Missing required parameter 'contentType' when calling ThemeActionsApi->ActivateStoreTheme"); } var localVarPath = "/themes/actions/activate"; var localVarPathParams = new Dictionary <String, String>(); var localVarQueryParams = new List <KeyValuePair <String, String> >(); var localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader); var localVarFormParams = new Dictionary <String, String>(); var localVarFileParams = new Dictionary <String, FileParameter>(); Object localVarPostBody = null; // to determine the Content-Type header String[] localVarHttpContentTypes = new String[] { "application/json" }; String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header String[] localVarHttpHeaderAccepts = new String[] { "application/json" }; String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) { localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); } if (accept != null) { localVarHeaderParams.Add("Accept", this.Configuration.ApiClient.ParameterToString(accept)); // header parameter } if (contentType != null) { localVarHeaderParams.Add("Content-Type", this.Configuration.ApiClient.ParameterToString(contentType)); // header parameter } if (body != null && body.GetType() != typeof(byte[])) { localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter } else { localVarPostBody = body; // byte array } // authentication (X-Auth-Token) required if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("X-Auth-Token"))) { localVarHeaderParams["X-Auth-Token"] = this.Configuration.GetApiKeyWithPrefix("X-Auth-Token"); } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (ExceptionFactory != null) { Exception exception = ExceptionFactory("ActivateStoreTheme", localVarResponse); if (exception != null) { throw exception; } } return(new ApiResponse <NoContent>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)), (NoContent)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(NoContent)))); }
/// <summary> /// Activate a Theme Actives a store *Theme*. This returns a 204 response upon success. /// </summary> /// <exception cref="Themes.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body">Request parameters.</param> /// <param name="accept"></param> /// <param name="contentType"></param> /// <returns>Task of NoContent</returns> public async System.Threading.Tasks.Task <NoContent> ActivateStoreThemeAsync(Activate1 body, string accept, string contentType) { ApiResponse <NoContent> localVarResponse = await ActivateStoreThemeAsyncWithHttpInfo(body, accept, contentType); return(localVarResponse.Data); }
/// <summary> /// Activate a Theme Actives a store *Theme*. This returns a 204 response upon success. /// </summary> /// <exception cref="Themes.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="body">Request parameters.</param> /// <param name="accept"></param> /// <param name="contentType"></param> /// <returns>NoContent</returns> public NoContent ActivateStoreTheme(Activate1 body, string accept, string contentType) { ApiResponse <NoContent> localVarResponse = ActivateStoreThemeWithHttpInfo(body, accept, contentType); return(localVarResponse.Data); }