public async Task <List <SpfDomainStatsDto> > GetSpfDomainStatsDto(string domain, string provider, string ip, DateTime startDate,
                                                                           DateTime endDate)
        {
            provider = _providerDetailsProvider.GetProviderAliasIn(provider);
            List <SpfDomainStats> spfDomainStats = await _aggregateReportApiDao.GetSpfDomainStats(domain, provider, ip, startDate, endDate);


            string providerAlias    = _providerDetailsProvider.GetProviderAliasOut(provider);
            string providerMarkdown = _providerDetailsProvider.GetProviderMarkdown(provider);


            List <SpfDomainStatsDto> spfDomainStatsDto = new List <SpfDomainStatsDto>();

            foreach (SpfDomainStats spfDomainStat in spfDomainStats)
            {
                SpfDomainStatsDto spfDomainDto = _spfDomainStatsMapper.Map(spfDomainStat, providerAlias, providerMarkdown);
                spfDomainStatsDto.Add(spfDomainDto);
            }

            return(spfDomainStatsDto);
        }
Ejemplo n.º 2
0
        public async Task CheckGetSpfDomainStatsDtoReturnsSpfDomainStatsDto()
        {
            string domain    = "ncsc.gov.uk";
            string ip        = "192.168.72.11";
            string spfDomain = "ncsc.gov.uk";

            string provider = "testProvider";
            string alias    = "testAlias";
            string markdown = "testMarkdown";

            A.CallTo(() => _providerDetailsProvider.GetProviderAliasIn(alias))
            .Returns(provider);
            A.CallTo(() => _providerDetailsProvider.GetProviderAliasOut(provider))
            .Returns(alias);
            A.CallTo(() => _providerDetailsProvider.GetProviderMarkdown(provider))
            .Returns(markdown);

            SpfDomainStats spfDomainStat = new SpfDomainStats(domain, provider, ip, spfDomain, 5, 10);

            List <SpfDomainStats> spfDomainStats = new List <SpfDomainStats>()
            {
                spfDomainStat
            };

            A.CallTo(() => _aggregateReportApiDao.GetSpfDomainStats(domain, provider, ip,
                                                                    A <DateTime> ._, A <DateTime> ._))
            .Returns(Task.FromResult(spfDomainStats));

            SpfDomainStatsDto spfDomainStatsDto =
                new SpfDomainStatsDto(domain, provider, ip, spfDomain, 5, 10, alias, markdown);

            A.CallTo(() => _spfDomainStatsMapper.Map(spfDomainStat, alias, markdown))
            .Returns(spfDomainStatsDto);

            List <SpfDomainStatsDto> spfDomainStatsDtoResult =
                await _aggregateReportService.GetSpfDomainStatsDto(domain, alias, ip, DateTime.MinValue,
                                                                   DateTime.MaxValue);

            Assert.AreSame(spfDomainStatsDto, spfDomainStatsDtoResult[0]);
        }