public void NamesAreConvertedToCamelCase(string input, string result) { var resolver = new CustomPropertyNamesContractResolver(); var name = resolver.GetResolvedPropertyName(input); Assert.Equal(result, name); }
public async Task <ApplicationDetails> UpdateApplicationFeatureAsync <TFeatureValue>( ClientContext context, ApplicationDetails applicationDetails, Expression <Func <ApplicationFeatures, TFeatureValue> > feature, TFeatureValue value) { await Configure.AwaitFalse(); var member = feature.Body as MemberExpression; if (member == null) { throw new ArgumentException($"Expression '{feature}' does not refer to a property.", nameof(feature)); } var property = member.Member as PropertyInfo; if (property == null) { throw new ArgumentException($"Expression '{feature}' does not refer to a property.", nameof(feature)); } var originalValue = property.GetValue(applicationDetails.Features); if (value.Equals(originalValue)) { return(applicationDetails); } var jsonProperty = property.GetCustomAttribute <JsonPropertyAttribute>(); var featureType = jsonProperty?.PropertyName ?? _resolver.GetResolvedPropertyName(property.Name); var featureValue = typeof(TFeatureValue) == typeof(bool) ? ((bool)(object)value ? "yes" : "no") : value.ToString(); var uriBuilder = new AppleDeveloperRequestUriBuilder( new RestUri(this.UrlProvider.UpdateApplicationUrl, new { platform = applicationDetails.Platform })); uriBuilder.AddQueryValues(new Dictionary <string, string> { { "teamId", applicationDetails.TeamId }, { "displayId", applicationDetails.Id }, { "featureType", featureType }, { "featureValue", featureValue } }); var request = RestRequest.Post(uriBuilder.ToUri()); var response = await this.SendAsync <Result <ApplicationDetails> >(context, request); this.CheckResultForErrors(response.Content); property.SetValue(applicationDetails.Features, value); return(applicationDetails); }
private static string ConvertName(string name) { return(_resolver.GetResolvedPropertyName(name)); }