private static IEnumerable<PlayerModel> FilterOnCurrentAbility( SearchPlayersRequest request, IEnumerable<PlayerModel> players) { if (request.CurrentAbility.HasValue) players = players.Where(p => p.CurrentAbility >= request.CurrentAbility.Value); return players; }
private static IEnumerable<PlayerModel> FilterOnName( SearchPlayersRequest request, IEnumerable<PlayerModel> players) { if (!string.IsNullOrWhiteSpace(request.Name)) players = players.Where(p => p.Name.Contains(request.Name)); return players; }
private static IEnumerable<PlayerModel> FilterOnAge( SearchPlayersRequest request, IEnumerable<PlayerModel> players) { if (request.Age.HasValue) players = players.Where(p => p.Age <= request.Age.Value); return players; }
public void PublishingSearchPlayersRequestSendsRequestToProducerBoundary() { var request = new SearchPlayersRequest(); _eventAggregator.Publish(request); _mockProducerBoundary.Verify(s => s.SearchPlayers(request, _mockConsumerBoundary.Object), Times.Once()); }
public void SearchPlayers(SearchPlayersRequest request, SearchPlayersConsumerBoundary consumerBoundary) { var players = _gateway.GetPlayers(request); var response = new SearchPlayersResponse { Players = ConvertPlayers(players) }; consumerBoundary.SetPlayers(response); }
public IEnumerable<Player> GetPlayers(SearchPlayersRequest request) { var players = _context.Players; players = FilterOnAge(request, players); players = FilterOnCurrentAbility(request, players); players = FilterOnName(request, players); players = FilterOnPosition(request, players); players = FiliterOnPotentialAbility(request, players); return players.Select(Player.CreatePlayer); }
public SearchForPlayersSteps() { _context = new FakeContext(); _consumerBoundary = new FakeSearchPlayersConsumerBoundary(); _playerGateway = new PlayerGatewayImp(_context); _interactor = new SearchPlayersInteractor(_playerGateway); _request = new SearchPlayersRequest { Position = new Position() }; }
private static IEnumerable<PlayerModel> FilterOnPosition( SearchPlayersRequest request, IEnumerable<PlayerModel> players) { if (request.Position == null) return players; if (request.Position.Ability > 0) { players = players .Where(p => p.Positions != null) .Where(p => p.Positions.Any(po => po.Ability >= request.Position.Ability)); } if (!string.IsNullOrWhiteSpace(request.Position.Name)) { players = players .Where(p => p.Positions != null) .Where(p => p.Positions.Any(po => po.Name == request.Position.Name)); } return players; }
private void HandleSearchPlayersRequest(SearchPlayersRequest request) { _producerBoundary.SearchPlayers(request, _consumerBoundary); }