public async Task ListShouldReturnAllRecords() { // Arrange var icon = new BuildingBlockIcon(Guid.NewGuid()); RepositoryHelper.ForValidation.CreateValidation(Guid.NewGuid(), "name-1", "nameOnApplication", "description", "instruction", icon); RepositoryHelper.ForValidation.CreateValidation(Guid.NewGuid(), "name-2", "nameOnApplication", "description", "instruction", icon); RepositoryHelper.ForValidation.CreateValidation(Guid.NewGuid(), "name-3", "nameOnApplication", "description", "instruction", icon); // Act var result = await _repository.ListAsync(null, null, null); // Assert result.Should().HaveCount(3); }
public async Task <Result> Handle(ListValidationQuery request, CancellationToken cancellationToken) { Result result; try { Expression <Func <Validation, bool> > filter = null; int?skip = request.Skip.ToNullableInt(); int?top = request.Top.ToNullableInt(); var validationDomains = await _validationReadRepository.ListAsync(filter, skip, top); var validationModels = _mapper.Map <IEnumerable <ValidationModel> >(validationDomains); var count = validationModels.Count(); var sourcesModel = new ValidationsModel { Value = validationModels, Count = count, NextLink = null }; result = Result.Ok(sourcesModel); } catch (FilterODataException) { result = Result.Fail(new System.Collections.Generic.List <Failure>() { new HandlerFault() { Code = HandlerFaultCode.InvalidQueryFilter.Name, Message = HandlerFailures.InvalidQueryFilter, Target = "$filter" } } ); } catch { result = Result.Fail(CustomFailures.ListValidationFailure); } return(result); }