private void SetupTemporaryExposureKeyExport() { var data = new List <TemporaryExposureKey> { new TemporaryExposureKey { CreatedOn = DateTime.UtcNow.Date, Id = Guid.NewGuid(), KeyData = Encoding.ASCII.GetBytes("keyData1"), TransmissionRiskLevel = RiskLevel.RISK_LEVEL_LOW, ReportType = ReportType.CONFIRMED_TEST, DaysSinceOnsetOfSymptoms = 1 }, new TemporaryExposureKey { CreatedOn = DateTime.UtcNow.Date.AddDays(-12), Id = Guid.NewGuid(), KeyData = Encoding.ASCII.GetBytes("keyData2"), TransmissionRiskLevel = RiskLevel.RISK_LEVEL_HIGH, ReportType = ReportType.CONFIRMED_TEST, DaysSinceOnsetOfSymptoms = 2 } }; ExposureKeyMapper mapper = new ExposureKeyMapper(_epochConverter); _exportBatch = mapper.FromEntityToProtoBatch(data); }
public void FromEntityToProtoBatch_GiveEntityList_ShouldReturnCorrectProtoBatchModel() { int listCount = 3; var keys = CreateMockedListExposureKeys(listCount); var keysByTime = keys.OrderBy(k => k.CreatedOn); var startTimes = new DateTimeOffset(keysByTime.First().CreatedOn); var endTimes = new DateTimeOffset(keysByTime.Last().CreatedOn); var mapper = new ExposureKeyMapper(_epochConverter); var protoBatch = mapper.FromEntityToProtoBatch(keys); Assert.AreEqual(listCount, protoBatch.Keys.Count); Assert.AreEqual(protoBatch.BatchNum, 1); Assert.AreEqual(protoBatch.BatchSize, 1); Assert.AreEqual(protoBatch.StartTimestamp, startTimes.ToUnixTimeSeconds()); Assert.AreEqual(protoBatch.EndTimestamp, endTimes.ToUnixTimeSeconds()); Assert.AreEqual(protoBatch.Region, "NO"); Assert.IsInstanceOf <Domain.Proto.TemporaryExposureKeyExport>(protoBatch); }
private void SetupTemporaryExposureKeyExport() { var data = new List <TemporaryExposureKey> { new TemporaryExposureKey() { CreatedOn = DateTime.UtcNow.Date, Id = Guid.NewGuid(), KeyData = Encoding.ASCII.GetBytes("keyData1"), TransmissionRiskLevel = RiskLevel.RISK_LEVEL_LOW, }, new TemporaryExposureKey() { CreatedOn = DateTime.UtcNow.Date.AddDays(-12), Id = Guid.NewGuid(), KeyData = Encoding.ASCII.GetBytes("keyData2"), TransmissionRiskLevel = RiskLevel.RISK_LEVEL_HIGH, } }; ExposureKeyMapper mapper = new ExposureKeyMapper(); _exportBatch = mapper.FromEntityToProtoBatch(data); }