/// <summary> /// Initialize a new instance of <see cref="SkipQueryOption"/> based on the raw $skip value and /// an EdmModel from <see cref="ODataQueryContext"/>. /// </summary> /// <param name="rawValue">The raw value for $skip query. It can be null or empty.</param> /// <param name="context">The <see cref="ODataQueryContext"/> which contains the <see cref="IEdmModel"/> and some type information</param> public SkipQueryOption(string rawValue, ODataQueryContext context) { if (context == null) { throw Error.ArgumentNull("context"); } if (String.IsNullOrEmpty(rawValue)) { throw Error.ArgumentNullOrEmpty("rawValue"); } Context = context; RawValue = rawValue; Validator = new SkipQueryValidator(); }
public void GetSkipQueryValidator_Returns_Validator() { // Arrange & Act & Assert Assert.NotNull(SkipQueryValidator.GetSkipQueryValidator(null)); // Arrange & Act & Assert ODataQueryContext context = new ODataQueryContext(EdmCoreModel.Instance, typeof(int)); Assert.NotNull(SkipQueryValidator.GetSkipQueryValidator(context)); // Arrange & Act & Assert IServiceProvider services = new ServiceCollection() .AddSingleton <SkipQueryValidator>().BuildServiceProvider(); context.RequestContainer = services; Assert.NotNull(SkipQueryValidator.GetSkipQueryValidator(context)); }
/// <summary> /// Initialize a new instance of <see cref="SkipQueryOption"/> based on the raw $skip value and /// an EdmModel from <see cref="ODataQueryContext"/>. /// </summary> /// <param name="rawValue">The raw value for $skip query. It can be null or empty.</param> /// <param name="context">The <see cref="ODataQueryContext"/> which contains the <see cref="IEdmModel"/> and some type information</param> /// <param name="queryOptionParser">The <see cref="ODataQueryOptionParser"/> which is used to parse the query option.</param> public SkipQueryOption(string rawValue, ODataQueryContext context, ODataQueryOptionParser queryOptionParser) { if (context == null) { throw Error.ArgumentNull("context"); } if (String.IsNullOrEmpty(rawValue)) { throw Error.ArgumentNullOrEmpty("rawValue"); } if (queryOptionParser == null) { throw Error.ArgumentNull("queryOptionParser"); } Context = context; RawValue = rawValue; Validator = SkipQueryValidator.GetSkipQueryValidator(context); _queryOptionParser = queryOptionParser; }
// This constructor is intended for unit testing only. internal SkipQueryOption(string rawValue, ODataQueryContext context) { if (context == null) { throw Error.ArgumentNull("context"); } if (String.IsNullOrEmpty(rawValue)) { throw Error.ArgumentNullOrEmpty("rawValue"); } Context = context; RawValue = rawValue; Validator = SkipQueryValidator.GetSkipQueryValidator(context); _queryOptionParser = new ODataQueryOptionParser( context.Model, context.ElementType, context.NavigationSource, new Dictionary <string, string> { { "$skip", rawValue } }); }
public SkipQueryValidatorTest() { _validator = new SkipQueryValidator(); _context = ValidationTestHelper.CreateCustomerContext(); }