public void Test() { DataFilter.IsEnabled <ISoftDelete>().ShouldBeFalse(); var filterContext = new FakeFilterContext(); DataFilterDescriptor.BuildFilterExpression <SoftDeleteEntity>(DataFilter, filterContext).Compile()(new SoftDeleteEntity(true)).ShouldBeTrue(); DataFilterDescriptor.BuildFilterExpression <SoftDeleteEntity>(DataFilter, filterContext).Compile()(new SoftDeleteEntity(false)).ShouldBeTrue(); using (DataFilter.Enable <ISoftDelete>()) { DataFilterDescriptor.BuildFilterExpression <SoftDeleteEntity>(DataFilter, filterContext).Compile()(new SoftDeleteEntity(true)).ShouldBeFalse(); DataFilterDescriptor.BuildFilterExpression <SoftDeleteEntity>(DataFilter, filterContext).Compile()(new SoftDeleteEntity(false)).ShouldBeTrue(); using (DataFilter.Disable <ISoftDelete>()) { DataFilterDescriptor.BuildFilterExpression <SoftDeleteEntity>(DataFilter, filterContext).Compile()(new SoftDeleteEntity(true)).ShouldBeTrue(); DataFilterDescriptor.BuildFilterExpression <SoftDeleteEntity>(DataFilter, filterContext).Compile()(new SoftDeleteEntity(false)).ShouldBeTrue(); } DataFilterDescriptor.BuildFilterExpression <SoftDeleteEntity>(DataFilter, filterContext).Compile()(new SoftDeleteEntity(true)).ShouldBeFalse(); DataFilterDescriptor.BuildFilterExpression <SoftDeleteEntity>(DataFilter, filterContext).Compile()(new SoftDeleteEntity(false)).ShouldBeTrue(); } DataFilterDescriptor.BuildFilterExpression <SoftDeleteEntity>(DataFilter, filterContext).Compile()(new SoftDeleteEntity(true)).ShouldBeTrue(); DataFilterDescriptor.BuildFilterExpression <SoftDeleteEntity>(DataFilter, filterContext).Compile()(new SoftDeleteEntity(false)).ShouldBeTrue(); }
/// <summary> /// /// </summary> /// <typeparam name="TFilter"></typeparam> /// <param name="descriptor"></param> /// <param name="expression"></param> /// <returns></returns> public static DataFilterDescriptor Expression <TFilter>(this DataFilterDescriptor <TFilter> descriptor, Expression <Func <TFilter, bool> > expression) where TFilter : class { descriptor.FilterExpression = expression; return(descriptor); }
public DataFilter_Integrated_Tests() { DataFilter = ServiceProvider.GetService <IDataFilter>(); DataFilterOptions = ServiceProvider.GetService <IOptions <DataFilterOptions> >().Value; DataFilterDescriptor = DataFilterOptions.Descriptors.GetValueOrDefault(typeof(ISoftDelete)); }
/// <summary> /// /// </summary> /// <param name="descriptor"></param> /// <returns></returns> public static DataFilterDescriptor Disable <TFilter>(this DataFilterDescriptor <TFilter> descriptor) where TFilter : class { descriptor.IsEnabled = false; return(descriptor); }