public override void ValidateArgument(ArgumentExceptionDetails details) { var value = (GamesFilterAttributes)details.Value; if (value == null) { return; } SortingObject sortingObject = value.SortingObject; PublishingDatePeriod publishingDatePeriod = value.PublishingDatePeriod; decimal minPrice = value.MinPrice; decimal maxPrice = value.MaxPrice; if (!Enum.IsDefined(sortingObject.GetType(), sortingObject) || !Enum.IsDefined(publishingDatePeriod.GetType(), publishingDatePeriod)) { details.Message = "Undefined value of enum"; throw new InvalidArgumentException(details); } if (minPrice < 0 || maxPrice < 0) { details.Message = "Price must be more or equal then zero"; throw new InvalidArgumentException(details); } if (minPrice > maxPrice) { details.Message = "Min price must be less then max price"; throw new InvalidArgumentException(details); } }
private void SetDataForGettingFilteredGames(GamesFilterAttributes attributes) { const SortingObject anySortingObject = SortingObject.New; const PageSize anyPageSize = PageSize.OneHundredItems; attributes.Genres = new List <int>() { It.IsAny <int>() }; attributes.PlatformTypes = new List <int>() { It.IsAny <int>() }; attributes.Publishers = new List <int>() { It.IsAny <int>() }; attributes.SortingObject = anySortingObject; attributes.GameNameSearchingString = "some searching string"; attributes.PageInfo = new PageInfo() { PageSize = anyPageSize }; _pipelineMock.Setup(m => m.Register(It.IsAny <IFilter <Game> >())) .Returns(_pipelineMock.Object); _pipelineMock.Setup(m => m.Process(It.IsAny <IQueryable <Game> >())) .Returns(It.IsAny <IQueryable <Game> >()); }
public GamesBySortingObjectFilter(SortingObject sortingObject) { _sortingObject = sortingObject; }