Exemple #1
0
        private static QueryResult <string> CreateResultWithAggregatorAndAppendedList()
        {
            var resultListForAppend = new List <string>()
            {
                "d", "e"
            };

            ServiceAggregator aggregator = new ServiceAggregator();

            aggregator.AttachService("b");
            aggregator.AttachService("c");
            var fromAggregator = new QueryResult <string>("a", aggregator);

            return(fromAggregator.AppendedWith(new QueryResult <string>(resultListForAppend)));
        }
        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}");
        }
 public static void Aggregate()
 {
     DbAggregator.AggregateDataBase();
     ServiceAggregator.AggregateService();
 }