public void GetMostActive_Success_ReturnsMostActive()
        {
            var fixture              = new Fixture();
            var topCount             = fixture.Create <int>();
            var count                = fixture.Create <Generator <int> >().First(z => z > topCount);
            var agents               = fixture.CreateMany <Agent>(count).ToList();
            var listingCountPerAgent = new ListingCountPerAgent(agents);
            var expectedResult       = listingCountPerAgent.OrderByDescending(z => z.Value.ListingCount).Take(topCount).ToDictionary(z => z.Key, z => z.Value);

            var result = listingCountPerAgent.ToResult().GetMostActive(topCount);

            result.Value.Should().BeEquivalentTo(expectedResult);
        }
예제 #2
0
        public Result <ListingCountPerAgent> Parse(IList <Result <AgentCollection> > results, IList <Agent> initialResults)
        {
            var listingCountPerAgent = new ListingCountPerAgent(initialResults);

            if (results.Any(z => z.IsFailed))
            {
                return(results.First(z => z.IsFailed).ToResult());
            }
            foreach (var r in results)
            {
                listingCountPerAgent.Update(r.Value.FetchedAgents);
            }
            return(Result.Ok(listingCountPerAgent));
        }