public void Ctor_Create_Storage_File() { // Arrange var fileContents = new StringBuilder(); InitializeMocks(fileContents, fileExists: false, dirExists: false); directoryMock .Setup(x => x.Create(Path.GetDirectoryName(TelemetryDataRepository.GetStorageFilePath()))); fileMock .Setup(x => x.CreateText(TelemetryDataRepository.GetStorageFilePath())) .Returns(() => new StringWriter(fileContents)); // Act var repository = new TelemetryDataRepository(fileMock.Object, directoryMock.Object, watcherFactoryMock.Object); // Assert RemoveLineEndings(fileContents.ToString()).Should().Be(RemoveLineEndings(@"<?xml version=""1.0"" encoding=""utf-16""?> <TelemetryData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <IsAnonymousDataShared>true</IsAnonymousDataShared> <NumberOfDaysOfUse>0</NumberOfDaysOfUse> <InstallationDate>0001-01-01T00:00:00.0000000+00:00</InstallationDate> <LastSavedAnalysisDate>0001-01-01T00:00:00.0000000+00:00</LastSavedAnalysisDate> <LastUploadDate>0001-01-01T00:00:00.0000000+00:00</LastUploadDate> </TelemetryData>")); Mock.VerifyAll(fileMock, directoryMock, watcherFactoryMock); }
public void Ctor_Reads_Value_From_File() { // Arrange var fileContents = new StringBuilder(@"<?xml version=""1.0"" encoding=""utf-16""?> <TelemetryData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <IsAnonymousDataShared>false</IsAnonymousDataShared> <NumberOfDaysOfUse>10</NumberOfDaysOfUse> <InstallationDate>2017-03-15T06:15:42.1234567+01:00</InstallationDate> <LastSavedAnalysisDate>2018-03-15T06:15:42.1234567+01:00</LastSavedAnalysisDate> <LastUploadDate>2019-03-15T06:15:42.1234567+01:00</LastUploadDate> </TelemetryData>"); InitializeMocks(fileContents, fileExists: true, dirExists: true); // Act var repository = new TelemetryDataRepository(fileMock.Object, directoryMock.Object, watcherFactoryMock.Object); // Assert repository.Data.IsAnonymousDataShared.Should().BeFalse(); repository.Data.NumberOfDaysOfUse.Should().Be(10); repository.Data.InstallationDate.Should().Be(new DateTimeOffset(new DateTime(2017, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1))); repository.Data.LastSavedAnalysisDate.Should().Be(new DateTimeOffset(new DateTime(2018, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1))); repository.Data.LastUploadDate.Should().Be(new DateTimeOffset(new DateTime(2019, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1))); Mock.VerifyAll(fileMock, directoryMock, watcherFactoryMock); }
public void Can_Read_Old_TelemetryXml() { var fileContents = new StringBuilder(@"<?xml version=""1.0"" encoding=""utf-8""?> <TelemetryData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <IsAnonymousDataShared>false</IsAnonymousDataShared> <InstallationDate>1999-12-31T23:59:59.9999999</InstallationDate> <LastSavedAnalysisDate>1999-12-31T23:59:59.9999999</LastSavedAnalysisDate> <NumberOfDaysOfUse>5807</NumberOfDaysOfUse> <LastUploadDate>1999-12-31T23:59:59.9999999</LastUploadDate> </TelemetryData>"); InitializeMocks(fileContents, fileExists: true, dirExists: true); // Act var repository = new TelemetryDataRepository(fileMock.Object, directoryMock.Object, watcherFactoryMock.Object); // Assert repository.Data.InstallationDate.Should().Be(new DateTimeOffset(1999, 12, 31, 23, 59, 59, 999, DateTimeOffset.Now.Offset).AddTicks(9999)); repository.Data.LastSavedAnalysisDate.Should().Be(new DateTimeOffset(1999, 12, 31, 23, 59, 59, 999, DateTimeOffset.Now.Offset).AddTicks(9999)); repository.Data.NumberOfDaysOfUse.Should().Be(5807); repository.Data.LastUploadDate.Should().Be(new DateTimeOffset(1999, 12, 31, 23, 59, 59, 999, DateTimeOffset.Now.Offset).AddTicks(9999)); repository.Data.IsAnonymousDataShared.Should().BeFalse(); Mock.VerifyAll(fileMock, directoryMock, watcherFactoryMock); }
public void Ctor_AlwaysReadValueFromFile() { // Arrange File.Delete(TelemetryDataRepository.GetStorageFilePath()); var repository = new TelemetryDataRepository(); repository.Data.IsAnonymousDataShared = false; repository.Data.InstallationDate = DateTime.MaxValue; repository.Data.LastSavedAnalysisDate = DateTime.MaxValue; repository.Data.NumberOfDaysOfUse = long.MaxValue; repository.Data.LastUploadDate = DateTime.MaxValue; repository.Save(); repository.Dispose(); // Act repository = new TelemetryDataRepository(); // Assert repository.Data.IsAnonymousDataShared.Should().BeFalse(); repository.Data.InstallationDate.Should().Be(DateTime.MaxValue); repository.Data.LastSavedAnalysisDate.Should().Be(DateTime.MaxValue); repository.Data.NumberOfDaysOfUse.Should().Be(long.MaxValue); repository.Data.LastUploadDate.Should().Be(DateTime.MaxValue); }
public void Save_SavesIntoXmlAllValuesOfData() { // Arrange File.Delete(TelemetryDataRepository.GetStorageFilePath()); var repository = new TelemetryDataRepository(); repository.Data.IsAnonymousDataShared = false; repository.Data.InstallationDate = DateTime.MaxValue; repository.Data.LastSavedAnalysisDate = DateTime.MaxValue; repository.Data.NumberOfDaysOfUse = long.MaxValue; repository.Data.LastUploadDate = DateTime.MaxValue; // Act repository.Save(); // Assert var stream = File.OpenRead(TelemetryDataRepository.GetStorageFilePath()); var serializer = new XmlSerializer(typeof(TelemetryData)); var data = serializer.Deserialize(stream) as TelemetryData; data.IsAnonymousDataShared.Should().BeFalse(); data.InstallationDate.Should().Be(DateTime.MaxValue); data.LastSavedAnalysisDate.Should().Be(DateTime.MaxValue); data.NumberOfDaysOfUse.Should().Be(long.MaxValue); data.LastUploadDate.Should().Be(DateTime.MaxValue); }
public void Ctor_Reads_Value_From_File() { // Arrange var fileContents = new StringBuilder(@"<?xml version=""1.0"" encoding=""utf-16""?> <TelemetryData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <IsAnonymousDataShared>false</IsAnonymousDataShared> <NumberOfDaysOfUse>10</NumberOfDaysOfUse> <InstallationDate>2017-03-15T06:15:42.1234567+01:00</InstallationDate> <LastSavedAnalysisDate>2018-03-15T06:15:42.1234567+01:00</LastSavedAnalysisDate> <LastUploadDate>2019-03-15T06:15:42.1234567+01:00</LastUploadDate> <ShowHotspot> <NumberOfRequests>20</NumberOfRequests> </ShowHotspot> <TaintVulnerabilities> <NumberOfIssuesInvestigatedLocally>66</NumberOfIssuesInvestigatedLocally> <NumberOfIssuesInvestigatedRemotely>55</NumberOfIssuesInvestigatedRemotely> </TaintVulnerabilities> <ServerNotifications> <IsDisabled>true</IsDisabled> <ServerNotificationCounters> <KeyValue> <Key>QUALITY_GATE</Key> <Value> <ReceivedCount>11</ReceivedCount> <ClickedCount>22</ClickedCount> </Value> </KeyValue> <KeyValue> <Key>NEW_ISSUES</Key> <Value> <ReceivedCount>33</ReceivedCount> <ClickedCount>44</ClickedCount> </Value> </KeyValue> </ServerNotificationCounters> </ServerNotifications> </TelemetryData>"); InitializeMocks(fileContents, fileExists: true, dirExists: true); // Act var repository = new TelemetryDataRepository(fileSystemMock.Object, watcherFactoryMock.Object); // Assert repository.Data.IsAnonymousDataShared.Should().BeFalse(); repository.Data.NumberOfDaysOfUse.Should().Be(10); repository.Data.InstallationDate.Should().Be(new DateTimeOffset(new DateTime(2017, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1))); repository.Data.LastSavedAnalysisDate.Should().Be(new DateTimeOffset(new DateTime(2018, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1))); repository.Data.LastUploadDate.Should().Be(new DateTimeOffset(new DateTime(2019, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1))); repository.Data.ShowHotspot.NumberOfRequests.Should().Be(20); repository.Data.TaintVulnerabilities.NumberOfIssuesInvestigatedRemotely.Should().Be(55); repository.Data.TaintVulnerabilities.NumberOfIssuesInvestigatedLocally.Should().Be(66); repository.Data.ServerNotifications.IsDisabled.Should().BeTrue(); repository.Data.ServerNotifications.ServerNotificationCounters["QUALITY_GATE"].ClickedCount.Should().Be(22); repository.Data.ServerNotifications.ServerNotificationCounters["QUALITY_GATE"].ReceivedCount.Should().Be(11); repository.Data.ServerNotifications.ServerNotificationCounters["NEW_ISSUES"].ClickedCount.Should().Be(44); repository.Data.ServerNotifications.ServerNotificationCounters["NEW_ISSUES"].ReceivedCount.Should().Be(33); Mock.VerifyAll(fileSystemMock, watcherFactoryMock); }
public void Instance_AutomaticallyReadFileOnChange() { // Arrange RetryHelper.RetryOnException(5, TimeSpan.FromSeconds(1), () => File.Delete(TelemetryDataRepository.GetStorageFilePath())); var repository = new TelemetryDataRepository(); repository.Data.IsAnonymousDataShared = false; repository.Data.InstallationDate = DateTime.MaxValue; repository.Data.LastSavedAnalysisDate = DateTime.MaxValue; repository.Data.NumberOfDaysOfUse = long.MaxValue; repository.Data.LastUploadDate = DateTime.MaxValue; var otherRepository = new TelemetryDataRepository(); // Act repository.Save(); Task.Delay(700).Wait(); // Assert otherRepository.Data.InstallationDate.Should().Be(DateTime.MaxValue); otherRepository.Data.LastSavedAnalysisDate.Should().Be(DateTime.MaxValue); otherRepository.Data.NumberOfDaysOfUse.Should().Be(long.MaxValue); otherRepository.Data.LastUploadDate.Should().Be(DateTime.MaxValue); otherRepository.Data.IsAnonymousDataShared.Should().BeFalse(); }
public void Can_Read_Old_TelemetryXml() { var fileContents = new StringBuilder(@"<?xml version=""1.0"" encoding=""utf-8""?> <TelemetryData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <IsAnonymousDataShared>false</IsAnonymousDataShared> <InstallationDate>1999-12-31T23:59:59.9999999</InstallationDate> <LastSavedAnalysisDate>1999-12-31T23:59:59.9999999</LastSavedAnalysisDate> <NumberOfDaysOfUse>5807</NumberOfDaysOfUse> <LastUploadDate>1999-12-31T23:59:59.9999999</LastUploadDate> </TelemetryData>"); // Calculate the expected result. // Previously, this test started failing when daylight saving was applied on the test agent // machine. Creating the local date first then converting it to a DateTimeOffset gives the // expected result regardless of the local time zone or whether the test agent machine is // automatically adjusting dor daylight saving time or not. var expectedDate = new DateTime(1999, 12, 31, 23, 59, 59, 999, DateTimeKind.Local).AddTicks(9999); var expectedDateTimeOffset = new DateTimeOffset(expectedDate); InitializeMocks(fileContents, fileExists: true, dirExists: true); // Act var repository = new TelemetryDataRepository(fileMock.Object, directoryMock.Object, watcherFactoryMock.Object); // Assert repository.Data.InstallationDate.Should().Be(expectedDateTimeOffset); repository.Data.LastSavedAnalysisDate.Should().Be(expectedDateTimeOffset); repository.Data.NumberOfDaysOfUse.Should().Be(5807); repository.Data.LastUploadDate.Should().Be(expectedDateTimeOffset); repository.Data.IsAnonymousDataShared.Should().BeFalse(); Mock.VerifyAll(fileMock, directoryMock, watcherFactoryMock); }
protected override void Initialize() { base.Initialize(); var activeSolutionTracker = this.GetMefService <IActiveSolutionBoundTracker>(); Debug.Assert(activeSolutionTracker != null, "Failed to resolve 'IActiveSolutionBoundTracker'."); var telemetryRepository = new TelemetryDataRepository(); this.telemetryManager = new TelemetryManager(activeSolutionTracker, telemetryRepository, new TelemetryClient(), new TelemetryTimer(telemetryRepository, new TimerFactory()), new KnownUIContextsWrapper()); }
public void Ctor_AlwaysCreateStorageFile() { // Arrange var filePath = TelemetryDataRepository.GetStorageFilePath(); RetryHelper.RetryOnException(5, TimeSpan.FromSeconds(1), () => File.Delete(filePath)); File.Exists(filePath).Should().BeFalse(); // Sanity test // Act var repository = new TelemetryDataRepository(); // Assert File.Exists(filePath).Should().BeTrue(); }
public void Ctor_AlwaysCreateStorageFileFolders() { // Arrange var filePath = TelemetryDataRepository.GetStorageFilePath(); var directoryPath = Path.GetDirectoryName(filePath); RetryHelper.RetryOnException(5, TimeSpan.FromSeconds(1), () => Directory.Delete(directoryPath, true)); Directory.Exists(directoryPath).Should().BeFalse(); // Sanity test // Act var repository = new TelemetryDataRepository(); // Assert Directory.Exists(directoryPath).Should().BeTrue(); }
public void Instance_Reads_File_On_Change() { // Arrange var fileContents = new StringBuilder(@"<?xml version=""1.0"" encoding=""utf-16""?> <TelemetryData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <IsAnonymousDataShared>false</IsAnonymousDataShared> <NumberOfDaysOfUse>10</NumberOfDaysOfUse> <InstallationDate>2010-03-15T06:15:42.1234567+01:00</InstallationDate> <LastSavedAnalysisDate>2010-03-15T06:15:42.1234567+01:00</LastSavedAnalysisDate> <LastUploadDate>2010-03-15T06:15:42.1234567+01:00</LastUploadDate> </TelemetryData>"); var fileSystemWatcherMock = new Mock <IFileSystemWatcher>(); InitializeMocks(fileContents, fileExists: true, dirExists: true, fileSystemWatcher: fileSystemWatcherMock.Object); var repository = new TelemetryDataRepository(fileMock.Object, directoryMock.Object, watcherFactoryMock.Object); // Act var newIsAnonymousDataShared = true; var newDaysOfUse = 15; var newInstallationDate = new DateTimeOffset(new DateTime(2017, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1)); var newLastSavedAnalysisDate = new DateTimeOffset(new DateTime(2018, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1)); var newLastUploadDate = new DateTimeOffset(new DateTime(2019, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1)); fileContents.Clear(); fileContents.Append($@"<?xml version=""1.0"" encoding=""utf-16""?> <TelemetryData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <IsAnonymousDataShared>{newIsAnonymousDataShared.ToString().ToLower()}</IsAnonymousDataShared> <NumberOfDaysOfUse>{newDaysOfUse}</NumberOfDaysOfUse> <InstallationDate>{newInstallationDate.ToString("o")}</InstallationDate> <LastSavedAnalysisDate>{newLastSavedAnalysisDate.ToString("o")}</LastSavedAnalysisDate> <LastUploadDate>{newLastUploadDate.ToString("o")}</LastUploadDate> </TelemetryData>"); fileSystemWatcherMock .Raise(x => x.Changed += null, new FileSystemEventArgs(WatcherChangeTypes.Changed, "", "")); // Assert repository.Data.IsAnonymousDataShared.Should().Be(newIsAnonymousDataShared); repository.Data.NumberOfDaysOfUse.Should().Be(newDaysOfUse); repository.Data.InstallationDate.Should().Be(newInstallationDate); repository.Data.LastSavedAnalysisDate.Should().Be(newLastSavedAnalysisDate); repository.Data.LastUploadDate.Should().Be(newLastUploadDate); Mock.VerifyAll(fileMock, directoryMock, watcherFactoryMock, fileSystemWatcherMock); }
public void IsAnonymousDataShared_ReturnsValueFromRepository() { // Arrange var solutionBindingTracker = new Mock <IActiveSolutionBoundTracker>(); var expectedValue = false; var telemetryRepository = new TelemetryDataRepository(); telemetryRepository.Data.IsAnonymousDataShared = expectedValue; var telemetryClient = new Mock <ITelemetryClient>(); var manager = new TelemetryManager(solutionBindingTracker.Object, telemetryRepository, telemetryClient.Object); // Act var result = manager.IsAnonymousDataShared; // Assert result.Should().Be(expectedValue); }
public void Ctor_Create_Storage_File() { var fileContents = new StringBuilder(); // Arrange InitializeMocks(fileContents, fileExists: false, dirExists: false); fileSystemMock .Setup(x => x.Directory.CreateDirectory(Path.GetDirectoryName(TelemetryDataRepository.GetStorageFilePath()))) .Returns(null as IDirectoryInfo); fileSystemMock .Setup(x => x.File.WriteAllText(TelemetryDataRepository.GetStorageFilePath(), It.IsAny <string>())) .Callback((string path, string content) => fileContents.Append(content)); // Act var repository = new TelemetryDataRepository(fileSystemMock.Object, watcherFactoryMock.Object); // Assert fileContents.ToString().Should().Be(@"<?xml version=""1.0"" encoding=""utf-16""?> <TelemetryData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <IsAnonymousDataShared>true</IsAnonymousDataShared> <NumberOfDaysOfUse>0</NumberOfDaysOfUse> <InstallationDate>0001-01-01T00:00:00.0000000+00:00</InstallationDate> <LastSavedAnalysisDate>0001-01-01T00:00:00.0000000+00:00</LastSavedAnalysisDate> <LastUploadDate>0001-01-01T00:00:00.0000000+00:00</LastUploadDate> <Analyses /> <ShowHotspot> <NumberOfRequests>0</NumberOfRequests> </ShowHotspot> <TaintVulnerabilities> <NumberOfIssuesInvestigatedLocally>0</NumberOfIssuesInvestigatedLocally> <NumberOfIssuesInvestigatedRemotely>0</NumberOfIssuesInvestigatedRemotely> </TaintVulnerabilities> <ServerNotifications> <IsDisabled>false</IsDisabled> <ServerNotificationCounters /> </ServerNotifications> </TelemetryData>"); Mock.VerifyAll(fileSystemMock, watcherFactoryMock); }
private void InitializeMocks(StringBuilder fileContents, bool fileExists, bool dirExists, IFileSystemWatcher fileSystemWatcher = null) { fileMock = new Mock <IFile>(MockBehavior.Strict); fileMock .Setup(x => x.OpenText(TelemetryDataRepository.GetStorageFilePath())) .Returns(() => new StringReader(fileContents.ToString())); fileMock .Setup(x => x.Exists(TelemetryDataRepository.GetStorageFilePath())) .Returns(fileExists); directoryMock = new Mock <IDirectory>(MockBehavior.Strict); directoryMock .Setup(x => x.Exists(Path.GetDirectoryName(TelemetryDataRepository.GetStorageFilePath()))) .Returns(dirExists); watcherFactoryMock = new Mock <IFileSystemWatcherFactory>(MockBehavior.Strict); watcherFactoryMock .Setup(x => x.Create()) .Returns(fileSystemWatcher ?? new Mock <IFileSystemWatcher>().Object); }
public void Instance_Reads_File_On_Change() { // Arrange var fileContents = new StringBuilder(@"<?xml version=""1.0"" encoding=""utf-16""?> <TelemetryData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <IsAnonymousDataShared>false</IsAnonymousDataShared> <NumberOfDaysOfUse>10</NumberOfDaysOfUse> <InstallationDate>2010-03-15T06:15:42.1234567+01:00</InstallationDate> <LastSavedAnalysisDate>2010-03-15T06:15:42.1234567+01:00</LastSavedAnalysisDate> <LastUploadDate>2010-03-15T06:15:42.1234567+01:00</LastUploadDate> </TelemetryData>"); var fileSystemWatcherMock = new Mock <IFileSystemWatcher>(); InitializeMocks(fileContents, fileExists: true, dirExists: true, fileSystemWatcher: fileSystemWatcherMock.Object); var repository = new TelemetryDataRepository(fileSystemMock.Object, watcherFactoryMock.Object); // Act const bool newIsAnonymousDataShared = true; const int newDaysOfUse = 15; const int newHotspotsRequests = 25; const int newTaintRedirects = 7; const int newTaintOpenedIssues = 9; const bool notificationsDisabled = true; const int qualityGateReceivedCount = 1234; const int qualityGateClickedCount = 5678; const int newIssuesReceivedCount = 8765; const int newIssuesClickedCount = 4321; var newInstallationDate = new DateTimeOffset(new DateTime(2017, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1)); var newLastSavedAnalysisDate = new DateTimeOffset(new DateTime(2018, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1)); var newLastUploadDate = new DateTimeOffset(new DateTime(2019, 3, 15, 6, 15, 42, 123).AddTicks(4567), TimeSpan.FromHours(1)); fileContents.Clear(); fileContents.Append($@"<?xml version=""1.0"" encoding=""utf-16""?> <TelemetryData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <IsAnonymousDataShared>{newIsAnonymousDataShared.ToString().ToLower()}</IsAnonymousDataShared> <NumberOfDaysOfUse>{newDaysOfUse}</NumberOfDaysOfUse> <InstallationDate>{newInstallationDate.ToString("o")}</InstallationDate> <LastSavedAnalysisDate>{newLastSavedAnalysisDate.ToString("o")}</LastSavedAnalysisDate> <LastUploadDate>{newLastUploadDate.ToString("o")}</LastUploadDate> <ShowHotspot> <NumberOfRequests>{newHotspotsRequests}</NumberOfRequests> </ShowHotspot> <TaintVulnerabilities> <NumberOfIssuesInvestigatedLocally>{newTaintOpenedIssues}</NumberOfIssuesInvestigatedLocally> <NumberOfIssuesInvestigatedRemotely>{newTaintRedirects}</NumberOfIssuesInvestigatedRemotely> </TaintVulnerabilities> <ServerNotifications> <IsDisabled>{notificationsDisabled.ToString().ToLower()}</IsDisabled> <ServerNotificationCounters> <KeyValue> <Key>QUALITY_GATE</Key> <Value> <ReceivedCount>{qualityGateReceivedCount}</ReceivedCount> <ClickedCount>{qualityGateClickedCount}</ClickedCount> </Value> </KeyValue> <KeyValue> <Key>NEW_ISSUES</Key> <Value> <ReceivedCount>{newIssuesReceivedCount}</ReceivedCount> <ClickedCount>{newIssuesClickedCount}</ClickedCount> </Value> </KeyValue> </ServerNotificationCounters> </ServerNotifications> </TelemetryData>"); fileSystemWatcherMock .Raise(x => x.Changed += null, new FileSystemEventArgs(WatcherChangeTypes.Changed, "", "")); // Assert repository.Data.IsAnonymousDataShared.Should().Be(newIsAnonymousDataShared); repository.Data.NumberOfDaysOfUse.Should().Be(newDaysOfUse); repository.Data.InstallationDate.Should().Be(newInstallationDate); repository.Data.LastSavedAnalysisDate.Should().Be(newLastSavedAnalysisDate); repository.Data.LastUploadDate.Should().Be(newLastUploadDate); repository.Data.ShowHotspot.NumberOfRequests.Should().Be(newHotspotsRequests); repository.Data.TaintVulnerabilities.NumberOfIssuesInvestigatedRemotely.Should().Be(newTaintRedirects); repository.Data.TaintVulnerabilities.NumberOfIssuesInvestigatedLocally.Should().Be(newTaintOpenedIssues); repository.Data.ServerNotifications.IsDisabled.Should().Be(notificationsDisabled); repository.Data.ServerNotifications.ServerNotificationCounters["QUALITY_GATE"].ClickedCount.Should().Be(qualityGateClickedCount); repository.Data.ServerNotifications.ServerNotificationCounters["QUALITY_GATE"].ReceivedCount.Should().Be(qualityGateReceivedCount); repository.Data.ServerNotifications.ServerNotificationCounters["NEW_ISSUES"].ClickedCount.Should().Be(newIssuesClickedCount); repository.Data.ServerNotifications.ServerNotificationCounters["NEW_ISSUES"].ReceivedCount.Should().Be(newIssuesReceivedCount); Mock.VerifyAll(fileSystemMock, watcherFactoryMock, fileSystemWatcherMock); }