public void SpfDomainStatsMapperShouldMapCorrectly()
        {
            SpfDomainStats    spfDomainStat = new SpfDomainStats("ncsc.gov.uk", "testProvider", "192.168.72.11", "ncsc.gov.uk", 5, 10);
            SpfDomainStatsDto result        = _spfDomainStatsMapper.Map(spfDomainStat, "testAlias", "testMarkdown");

            Assert.That(result.Domain, Is.EqualTo("ncsc.gov.uk"));
            Assert.That(result.Provider, Is.EqualTo("testProvider"));
            Assert.That(result.Ip, Is.EqualTo("192.168.72.11"));
            Assert.That(result.SpfDomain, Is.EqualTo("ncsc.gov.uk"));
            Assert.That(result.SpfPass, Is.EqualTo(5));
            Assert.That(result.SpfFail, Is.EqualTo(10));
            Assert.That(result.ProviderAlias, Is.EqualTo("testAlias"));
            Assert.That(result.ProviderMarkdown, Is.EqualTo("testMarkdown"));
        }
        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);
        }
コード例 #3
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]);
        }