Ejemplo n.º 1
0
        public void CoverageInfoMergeTest()
        {
            var coverageInfoType = new coverageInfo
            {
                level         = "first",
                live_coverage = true,
                coverage      = new[]
                {
                    new coverage {
                        includes = "coverage includes 1"
                    },
                    new coverage {
                        includes = "coverage includes 2"
                    },
                    new coverage {
                        includes = "coverage includes 3"
                    }
                },
                covered_from = "tv"
            };
            var coverageInfoDTO = new CoverageInfoDTO(coverageInfoType);
            var coverageInfo    = new CoverageInfo(coverageInfoDTO.Level, coverageInfoDTO.IsLive, coverageInfoDTO.Includes, coverageInfoDTO.CoveredFrom);

            Assert.IsNotNull(coverageInfo);
            Assert.AreEqual(coverageInfoType.level, coverageInfo.Level);
            Assert.AreEqual(coverageInfoType.live_coverage, coverageInfo.IsLive);
            Assert.AreEqual(CoveredFrom.Tv, coverageInfo.CoveredFrom);
            Assert.AreEqual(coverageInfoType.coverage.Length, coverageInfo.Includes.Count());
            Assert.AreNotEqual(coverageInfo.Includes.ToList()[0], coverageInfo.Includes.ToList()[2]);
        }
Ejemplo n.º 2
0
 private static void ValidateCoverageInfo(coverageInfo msg, CoverageInfoDTO dto)
 {
     Assert.AreEqual(msg.level, dto.Level);
     Assert.AreEqual(msg.live_coverage, dto.IsLive);
     Assert.AreEqual(CoveredFrom.Tv, dto.CoveredFrom);
     Assert.AreEqual(msg.coverage.Length, dto.Includes.Count());
     for (var i = 0; i < msg.coverage.Length; i++)
     {
         Assert.AreEqual(msg.coverage[i].includes, dto.Includes.ToArray()[i]);
     }
 }
Ejemplo n.º 3
0
        internal CoverageInfoDTO(coverageInfo coverageInfo)
        {
            Guard.Argument(coverageInfo, nameof(coverageInfo)).NotNull();
            Guard.Argument(coverageInfo.level, nameof(coverageInfo.level)).NotNull().NotEmpty();

            Level    = coverageInfo.level;
            IsLive   = coverageInfo.live_coverage;
            Includes = coverageInfo.coverage != null && coverageInfo.coverage.Any()
                ? new ReadOnlyCollection <string>(coverageInfo.coverage.Select(c => c.includes).ToList())
                : null;
            RestMapperHelper.TryGetCoveredFrom(coverageInfo.covered_from, out var coveredFrom);
            CoveredFrom = coveredFrom;
        }
Ejemplo n.º 4
0
        internal CoverageInfoDTO(coverageInfo coverageInfo)
        {
            Contract.Requires(coverageInfo != null);
            Contract.Requires(!string.IsNullOrEmpty(coverageInfo.level));

            Level    = coverageInfo.level;
            IsLive   = coverageInfo.live_coverage;
            Includes = coverageInfo.coverage != null && coverageInfo.coverage.Any()
                ? new ReadOnlyCollection <string>(coverageInfo.coverage.Select(c => c.includes).ToList())
                : null;
            CoveredFrom?coveredFrom;

            RestMapperHelper.TryGetCoveredFrom(coverageInfo.covered_from, out coveredFrom);
            CoveredFrom = coveredFrom;
        }