public async void Must_Throw_PropertyNotFoundException() { var binder = new DynamicFilterBinder(); var queryCollection = new QueryCollection(new Dictionary <string, StringValues>() { { "query", new StringValues("Nome=Bruno") } }); var vp = new QueryStringValueProvider(BindingSource.Query, queryCollection, CultureInfo.CurrentCulture); var context = GetBindingContext(vp, typeof(DynamicFilter <User>)); await Assert.ThrowsAsync <PropertyNotFoundException>(async() => await binder.BindModelAsync(context)); }
public async void Must_Match_Multiple_Users(string query, int count) { var binder = new DynamicFilterBinder(); var queryCollection = new QueryCollection(new Dictionary <string, StringValues>() { { "query", new StringValues(query) } }); var vp = new QueryStringValueProvider(BindingSource.Query, queryCollection, CultureInfo.CurrentCulture); var context = GetBindingContext(vp, typeof(DynamicFilter <User>)); await binder.BindModelAsync(context); var dynamicFilter = context.Result.Model as DynamicFilter <User>; var result = await new UserController().Get(dynamicFilter); Assert.Equal(count, result.Count); }
public async void Must_Order_Values(string query, string order, string firstName) { var binder = new DynamicFilterBinder(); var queryCollection = new QueryCollection(new Dictionary <string, StringValues>() { { "query", new StringValues(query) }, { $"order", new StringValues(order) } }); var vp = new QueryStringValueProvider(BindingSource.Query, queryCollection, CultureInfo.CurrentCulture); var context = GetBindingContext(vp, typeof(DynamicFilter <User>)); await binder.BindModelAsync(context); var dynamicFilter = context.Result.Model as DynamicFilter <User>; var result = await new UserController().Get(dynamicFilter); Assert.Equal(firstName, result.FirstOrDefault().Name); }