public UserExposureInfo(ExposureInformation exposureInformation) { Timestamp = DateTimeOffset.UnixEpoch.AddMilliseconds(exposureInformation.DateMillisSinceEpoch).UtcDateTime; Duration = TimeSpan.FromMilliseconds(exposureInformation.DurationInMillis); AttenuationValue = exposureInformation.AttenuationValue; TotalRiskScore = exposureInformation.TotalRiskScore; TransmissionRiskLevel = exposureInformation.TransmissionRiskLevel; }
public async void ExposureDetected_ExposureInformationHighRiskExposureDetected() { // Test Data var exposureConfiguration = new ExposureConfiguration() { GoogleExposureConfig = new ExposureConfiguration.GoogleExposureConfiguration() { MinimumRiskScore = 0 } }; var exposureSummary = new ExposureSummary() { MaximumRiskScore = 1 }; var exposureInformantion = new ExposureInformation() { AttenuationDurationsInMillis = new int[] { 0 }, AttenuationValue = 0, DateMillisSinceEpoch = 0, DurationInMillis = 0, TotalRiskScore = 2, TransmissionRiskLevel = RiskLevel.High }; var exposureInformationList = new List <ExposureInformation>() { exposureInformantion }; var enVersion = 2; // Mock Setup exposureDataCollectServer .Setup(x => x.UploadExposureDataAsync( It.IsAny <ExposureConfiguration>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <ExposureSummary>(), It.IsAny <List <ExposureInformation> >())); deviceInfoUtility.Setup(x => x.Model).Returns("UnitTest"); exposureRiskCalculationService .Setup(x => x.CalcRiskLevel(It.IsAny <DailySummary>(), It.IsAny <List <ExposureWindow> >(), It.IsAny <V1ExposureRiskCalculationConfiguration>())) .Returns(RiskLevel.High); // Test Case var unitUnderTest = CreateService(); await unitUnderTest.ExposureDetectedAsync(exposureConfiguration, enVersion, exposureSummary, exposureInformationList); // Assert localNotificationService .Verify(x => x.ShowExposureNotificationAsync(), Times.Once); var expectedSerializedData = JsonConvert.SerializeObject(exposureInformationList.Select(x => new UserExposureInfo(x))); secureStorageService .Verify(x => x.SetValue <string>("ExposureInformation", It.Is <string>(x => x == expectedSerializedData)), Times.Once); }
public ExposuresViewModel() { MessagingCenter.Instance.Subscribe <ExposureNotificationHandler>(this, "exposure_info_changed", h => Device.BeginInvokeOnMainThread(() => { ExposureInformation.Clear(); foreach (var i in LocalStateManager.Instance.ExposureInformation) { ExposureInformation.Add(i); } })); }
public ExposuresPageViewModel(INavigationService navigationService, IStatusBarPlatformSpecific statusBarPlatformSpecific) : base(navigationService, statusBarPlatformSpecific) { Title = Resources.AppResources.MainExposures; MessagingCenter.Instance.Subscribe <ExposureNotificationHandler>(this, "exposure_info_changed", h => Device.BeginInvokeOnMainThread(() => { ExposureInformation.Clear(); foreach (var i in LocalStateManager.Instance.ExposureInformation) { ExposureInformation.Add(i); } })); }
public async void ExposureDetected_ExposureInformationHighRiskExposureNotDetected() { // Test Data var exposureConfiguration = new ExposureConfiguration() { GoogleExposureConfig = new ExposureConfiguration.GoogleExposureConfiguration() { MinimumRiskScore = 3 } }; var exposureSummary = new ExposureSummary() { MaximumRiskScore = 1 }; var exposureInformantion = new ExposureInformation() { AttenuationDurationsInMillis = new int[] { 0 }, AttenuationValue = 0, DateMillisSinceEpoch = 0, DurationInMillis = 0, TotalRiskScore = 2, TransmissionRiskLevel = RiskLevel.High }; var exposureInformationList = new List <ExposureInformation>() { exposureInformantion }; var enVersion = 2; // Mock Setup exposureDataCollectServer .Setup(x => x.UploadExposureDataAsync( It.IsAny <ExposureConfiguration>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <ExposureSummary>(), It.IsAny <List <ExposureInformation> >())); deviceInfoUtility.Setup(x => x.Model).Returns("UnitTest"); // Test Case var unitUnderTest = CreateService(); await unitUnderTest.ExposureDetectedAsync(exposureConfiguration, enVersion, exposureSummary, exposureInformationList); // Assert localNotificationService .Verify(x => x.ShowExposureNotificationAsync(), Times.Never); secureStorageService .Verify(x => x.SetStringValue("ExposureInformation", It.IsAny <string>()), Times.Never); }