public AccountReference(string prefix, int number) { Ensure.String.HasLengthBetween(prefix, 2, 2, nameof(prefix)); EnsureArg.IsInRange(number, 1, 9999999, nameof(number)); Value = $"{prefix}{number}"; }
public void IsInRange_When_value_is_greater_than_upper_limit_It_throws_ArgumentException() { var spec = When_value_is_greater_than_upper_limit(); AssertIsRangeToHighScenario(spec.Value, spec.UpperLimit, () => Ensure.That(spec.Value, ParamName).IsInRange(spec.LowerLimit, spec.UpperLimit), () => EnsureArg.IsInRange(spec.Value, spec.LowerLimit, spec.UpperLimit, ParamName)); }
public void IsInRange_When_value_is_between_limits_It_should_not_throw() { var spec = When_value_is_between_limits(); ShouldNotThrow( () => Ensure.That(spec.Value, ParamName).IsInRange(spec.LowerLimit, spec.UpperLimit), () => EnsureArg.IsInRange(spec.Value, spec.LowerLimit, spec.UpperLimit, ParamName)); }
public void IsInRange_When_value_is_upper_limit_It_should_not_throw() { var spec = When_value_is_upper_limit(); ShouldNotThrow( () => Ensure.Comparable.IsInRange(spec.Value, spec.LowerLimit, spec.UpperLimit, ParamName), () => EnsureArg.IsInRange(spec.Value, spec.LowerLimit, spec.UpperLimit, ParamName), () => Ensure.That(spec.Value, ParamName).IsInRange(spec.LowerLimit, spec.UpperLimit)); }
public static float Enumerate(this Vector3 @this, int index) { EnsureArg.IsInRange(index, 0, 3, nameof(index)); return(index switch { 0 => @this.X, 1 => @this.Y, 2 => @this.Z, _ => throw new ApplicationException("Should not be reached.") });
public void IsInRange_When_value_is_between_limits_It_returns_passed_value() { var spec = When_value_is_between_limits(); var returnedValue = Ensure.That(spec.Value, ParamName).IsInRange(spec.LowerLimit, spec.UpperLimit); AssertReturnedAsExpected(returnedValue, spec.Value); Action a = () => EnsureArg.IsInRange(spec.Value, spec.LowerLimit, spec.UpperLimit, ParamName); a.ShouldNotThrow(); }
public async Task <IEnumerable <Category> > GetCategoriesWithProducts(int pageSize, int pageNumber, CancellationToken cancellationToken = default) { EnsureArg.IsInRange(pageSize, 1, 100, nameof(pageSize)); EnsureArg.IsGte(pageSize, 0, nameof(pageSize)); var result = await dashboardsClient.ExecuteCustomScriptCustomerAsync( string.Format(PagedCategoryWithProductsQueryFormat, pageSize, pageNumber), GetHeaders(), cancellationToken); if (result.IsError) { throw new ApiException("Execution failed with error: ", (int)HttpStatusCode.BadRequest, result.ErrorMessage); } return(mapper.Map <IEnumerable <Category> >(result)); }
public void IsInRange_Comparer_arg_is_used() { // sa < Sb < sc when case sensitive, but not when case insensitive var sa = "sa"; var Sb = "Sb"; var sc = "sc"; IComparer <string> ordinal = StringComparer.Ordinal; AssertIsRangeToLowScenario(Sb, sa, () => Ensure.That(Sb, ParamName).IsInRange(sa, sc, ordinal), () => EnsureArg.IsInRange(Sb, sa, sc, ordinal, ParamName)); // Validate with comparer (order is reversed) IComparer <string> ignoreCase = StringComparer.OrdinalIgnoreCase; ShouldNotThrow( () => Ensure.That(Sb, ParamName).IsInRange(sa, sc, ignoreCase), () => EnsureArg.IsInRange(Sb, sa, sc, ignoreCase, ParamName)); }
public GetExtendedQueryTagErrorsRequest(string path, int limit, int offset) { Path = EnsureArg.IsNotNullOrWhiteSpace(path, nameof(path)); Limit = EnsureArg.IsInRange(limit, 1, 200, nameof(limit)); Offset = EnsureArg.IsGte(offset, 0, nameof(offset)); }
public Record GetRecordByPosition(int position) { EnsureArg.IsInRange(position, 0, recordsList.Count - 1); return(recordsList.ElementAt(position)); }
public GetExtendedQueryTagsRequest(int limit, int offset) { Limit = EnsureArg.IsInRange(limit, 1, 200, nameof(limit)); Offset = EnsureArg.IsGte(offset, 0, nameof(offset)); }