public void CanDeserializeARecordFromTheService(
            HttpClientFixtureBuilder <Person> httpClientFixtureBuilder,
            IOptions <Config> config)
        {
            const string firstName = "Jeff";

            var httpClient = httpClientFixtureBuilder
                             .WithStatusCode(HttpStatusCode.OK)
                             .WithModel(model => model.With(p => p.FirstName, firstName))
                             .WithGet()
                             .Build();

            var service = new SampleTestService(httpClient, config);
            var people  = service.DeserialiseStream <Person>();

            people.Result.Count().Should().Be(1);
            people.Result.First().FirstName.Should().Be(firstName);
        }
        public void ServiceAggregatorCorrectlyAggregatesNumberOfGendersPerAge(
            HttpClientFixtureBuilder <Person> httpClientFixtureBuilder,
            IMapper <Person, PeopleViewModel> viewModelMapper,
            IOptions <Config> config)
        {
            var peopleMock = PeopleMock.WithMultipleGendersAndAges();

            var httpClient = httpClientFixtureBuilder
                             .WithStatusCode(HttpStatusCode.OK)
                             .WithModel(peopleMock)
                             .WithGet()
                             .Build();

            var service           = new SampleTestService(httpClient, config);
            var serviceAggregator = new ServiceAggregator <Person, PeopleViewModel>(service);
            var vm = serviceAggregator.AggregateOperation(viewModelMapper.Map).Result;

            vm.GendersByAge.Count.Should().Be(3, "There should be a record for each age group (3)");
            vm.GendersByAge.FirstOrDefault(v => v.Key == 22).Value.Genders.Count.Should().Be(2, "There should be a record per gender (2)");
        }
        public void ServiceAggregatorCorrectlyAggregatesFirstNamesAged23(
            HttpClientFixtureBuilder <Person> httpClientFixtureBuilder,
            IMapper <Person, PeopleViewModel> viewModelMapper,
            IOptions <Config> config)
        {
            var httpClient = httpClientFixtureBuilder
                             .WithStatusCode(HttpStatusCode.OK)
                             .WithAllModel(model => model.With(p => p.Age, 23), 3)
                             .WithGet()
                             .Build();

            var service           = new SampleTestService(httpClient, config);
            var serviceAggregator = new ServiceAggregator <Person, PeopleViewModel>(service);
            var vm = serviceAggregator.AggregateOperation(viewModelMapper.Map).Result;

            vm.Age.Should().Be(23);

            var firstNames = httpClientFixtureBuilder.HttpBodyModel.Select(x => x.FirstName).ToList();

            vm.FirstNames.Should().BeEquivalentTo(firstNames);
        }
        public void ServiceAggregatorCorrectlyAggregatesNamesForId42(
            HttpClientFixtureBuilder <Person> httpClientFixtureBuilder,
            IMapper <Person, PeopleViewModel> viewModelMapper,
            IOptions <Config> config)
        {
            var httpClient = httpClientFixtureBuilder
                             .WithStatusCode(HttpStatusCode.OK)
                             .WithModel(model => model.With(p => p.Id, 42))
                             .WithGet()
                             .Build();

            var service           = new SampleTestService(httpClient, config);
            var serviceAggregator = new ServiceAggregator <Person, PeopleViewModel>(service);
            var vm = serviceAggregator.AggregateOperation(viewModelMapper.Map).Result;

            vm.Id.Should().Be(42);

            var firstname = httpClientFixtureBuilder.HttpBodyModel.FirstOrDefault()?.FirstName;
            var lastname  = httpClientFixtureBuilder.HttpBodyModel.FirstOrDefault()?.LastName;

            vm.FullName.Should().Be($"{firstname} {lastname}");
        }