public void GetRealStateObjects_OnNotFoundResponse_ResourceNotFoundExceptionISThrown()
 {
     _httpClient       = new HttpClient(new ResourceNotFoundResponseHandler());
     _statisticsClient = new RealStateStatisticsClient(_httpClient, _mockPolicyService.Object);
     Assert.ThrowsAsync <ResourceNotFoundException>(async() =>
                                                    await _statisticsClient.GetRealStateObjects(true, _cancellationTokenSource.Token));
 }
 public void GetRealStateObjects_UnauthorizedResponse_UnauthorizedAccessExceptionISThrown()
 {
     _httpClient       = new HttpClient(new Unauthorized401ResponseHandler());
     _statisticsClient = new RealStateStatisticsClient(_httpClient, _mockPolicyService.Object);
     Assert.ThrowsAsync <UnauthorizedApiAccessException>(async() =>
                                                         await _statisticsClient.GetRealStateObjects(true, _cancellationTokenSource.Token));
 }
        public async Task <IEnumerable <MakelaarObject> > GetTopAgentsByObjects(bool withGarden)
        {
            var objectList = await _statisticsClient.GetRealStateObjects(withGarden, _cancellationTokenSource.Token);

            return(objectList.Objects.GroupBy(x => x.MakelaarId)
                   .OrderByDescending(g => g.Count()).Take(topNumberNeeded)
                   .ToList()
                   .Select(agentGroup => new MakelaarObject
            {
                MakelaarId = agentGroup.Key, ObjectsNumber = agentGroup.Count()
            })
                   .ToList());
        }