Beispiel #1
0
        public async Task <Status> Get()
        {
            var sites = _settingsHelper.GetSites().ToList();

            Trace.WriteLine("Sites: " + string.Join(", ", sites));
            var siteSet = new HashSet <string>(sites.Concat(sites.Select(s => s + "(staging)")), StringComparer.OrdinalIgnoreCase);

            WebSpacesListResponse spaces;

            try
            {
                var client = _clientHelper.GetWebSiteClient();
                spaces = await client.WebSpaces.ListAsync(CancellationToken.None);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                throw;
            }
            try
            {
                var siteLists = await Task.WhenAll(spaces.Select(space => ListWebSites(space.Name, siteSet)));

                Output = DtoCollection.Create(siteLists.SelectMany(l => l).Select(WebSiteDto.FromSdk).OrderBy(dto => dto.Name));
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                throw;
            }
            return(200);
        }
        public void MapsCollectionsFromDtoToDomain()
        {
            var dtoCollection = new DtoCollection();
            var dtos          = new IDto[]
            {
                new Dto1
                {
                    P0 = 10,
                    P1 = 11
                },
                new Dto2
                {
                    P0 = 20,
                    P2 = 22
                }
            };

            foreach (var to in dtos)
            {
                dtoCollection.Add(to);
            }

            var domainCollection = this.mapper.Map <DomainCollection>(dtoCollection);

            domainCollection.Entries.Count().ShouldBe(dtoCollection.Entries.Count());

            var domain1 = domainCollection.Entries.ElementAt(0).ShouldBeOfType <DomainType1>();

            domain1.Prop0.ShouldBe(10);
            domain1.Prop1.ShouldBe(11);

            var domain2 = domainCollection.Entries.ElementAt(1).ShouldBeOfType <DomainType2>();

            domain2.Prop0.ShouldBe(20);
            domain2.Prop2.ShouldBe(22);
        }