public void LogEvent(NodejsToolsLogEvent logEvent, object argument) { int val; switch (logEvent) { case NodejsToolsLogEvent.Launch: if ((int)argument != 0) { _debugLaunchCount++; } else { _normalLaunchCount++; } break; case NodejsToolsLogEvent.SurveyNewsFrequency: val = (int)argument; if (Enum.IsDefined(typeof(SurveyNewsPolicy), val)) { _surveyNewsPolicy = (SurveyNewsPolicy)val; } break; case NodejsToolsLogEvent.AnalysisLevel: val = (int)argument; if (Enum.IsDefined(typeof(AnalysisLevel), val)) { _analysisLevel = (AnalysisLevel)val; } break; } }
internal void SyncControlWithPageSettings(NodejsGeneralOptionsPage page) { SurveyNewsCheckCombo = page.SurveyNewsCheck; _waitOnAbnormalExit.Checked = page.WaitOnAbnormalExit; _waitOnNormalExit.Checked = page.WaitOnNormalExit; _editAndContinue.Checked = page.EditAndContinue; _checkForLongPaths.Checked = page.CheckForLongPaths; }
private async Task CheckSurveyNews(SurveyNewsFeed feed, SurveyNewsPolicy policy, DateTime lastChecked, bool forceCheck, string expectedNavigatedUrl, DateTime?expectedLastChecked) { string navigatedUrl = null; // Create the test objects var browser = Substitute.For <IWebBrowserServices>(); browser.When(x => x.OpenBrowser(Arg.Any <WebBrowserRole>(), Arg.Any <string>(), Arg.Any <bool>())).Do(x => { ((WebBrowserRole)x.Args()[0]).Should().Be(WebBrowserRole.News); navigatedUrl = (string)x.Args()[1]; }); var options = new MockSurveyNewsOptions(policy, lastChecked); var feedClient = new MockSurveyNewsFeedClient(feed); // Invoke the real survey/news service var service = new SurveyNewsService(feedClient, options, browser, Substitute.For <ICoreShell>()); await service.CheckSurveyNewsAsync(forceCheck); // Check that we navigated to the right url (or didn't navigate at all) navigatedUrl.Should().Be(expectedNavigatedUrl); // Check that the last checked date has been updated (or not updated at all) if (expectedLastChecked.HasValue) { var delta = options.SurveyNewsLastCheck - expectedLastChecked.Value; delta.Duration().Should().BeLessOrEqualTo(TimeSpan.FromSeconds(5)); } else { options.SurveyNewsLastCheck.Should().Be(lastChecked); } }
private async Task CheckSurveyNews(SurveyNewsFeed feed, SurveyNewsPolicy policy, DateTime lastChecked, bool forceCheck, string expectedNavigatedUrl, DateTime?expectedLastChecked) { // Create the test objects MockSurveyNewsBrowserLauncher browser = new MockSurveyNewsBrowserLauncher(); var options = new MockSurveyNewsOptions(policy, lastChecked); var feedClient = new MockSurveyNewsFeedClient(feed); // Invoke the real survey/news service var service = new SurveyNewsService(feedClient, options, browser); await service.CheckSurveyNewsAsync(forceCheck); // Check that we navigated to the right url (or didn't navigate at all) browser.NavigatedUrl.Should().Be(expectedNavigatedUrl); // Check that the last checked date has been updated (or not updated at all) if (expectedLastChecked.HasValue) { var delta = options.SurveyNewsLastCheck - expectedLastChecked.Value; delta.Duration().Should().BeLessOrEqualTo(TimeSpan.FromSeconds(5)); } else { options.SurveyNewsLastCheck.Should().Be(lastChecked); } }
internal void SyncControlWithPageSettings(NodejsGeneralOptionsPage page) { SurveyNewsCheckCombo = page.SurveyNewsCheck; _waitOnAbnormalExit.Checked = page.WaitOnAbnormalExit; _waitOnNormalExit.Checked = page.WaitOnNormalExit; _editAndContinue.Checked = page.EditAndContinue; _checkForLongPaths.Checked = page.CheckForLongPaths; _showBrowserAndNodeLabels.Checked = page.ShowBrowserAndNodeLabels; // Disable the show "browser" and "node" labels option when the user is in ES6 IntelliSense Preview mode _showBrowserAndNodeLabels.Enabled = NodejsPackage.Instance.IntellisenseOptionsPage.AnalysisLevel != AnalysisLevel.Preview; }
/// <summary> /// Resets settings back to their defaults. This should be followed by /// a call to <see cref="SaveSettingsToStorage" /> to commit the new /// values. /// </summary> public override void ResetSettings() { _surveyNewsCheck = SurveyNewsPolicy.CheckOnceWeek; _surveyNewsLastCheck = DateTime.MinValue; _surveyNewsFeedUrl = DefaultSurveyNewsFeedUrl; _surveyNewsIndexUrl = DefaultSurveyNewsIndexUrl; WaitOnAbnormalExit = true; WaitOnNormalExit = false; EditAndContinue = true; CheckForLongPaths = true; }
internal void SyncControlWithPageSettings(PythonToolsService pyService) { _showOutputWindowForVirtualEnvCreate.Checked = pyService.GeneralOptions.ShowOutputWindowForVirtualEnvCreate; _showOutputWindowForPackageInstallation.Checked = pyService.GeneralOptions.ShowOutputWindowForPackageInstallation; _elevatePip.Checked = pyService.GeneralOptions.ElevatePip; _autoAnalysis.Checked = pyService.GeneralOptions.AutoAnalyzeStandardLibrary; _updateSearchPathsForLinkedFiles.Checked = pyService.GeneralOptions.UpdateSearchPathsWhenAddingLinkedFiles; _unresolvedImportWarning.Checked = pyService.GeneralOptions.UnresolvedImportWarning; _clearGlobalPythonPath.Checked = pyService.GeneralOptions.ClearGlobalPythonPath; IndentationInconsistencySeverity = pyService.GeneralOptions.IndentationInconsistencySeverity; SurveyNewsCheck = pyService.GeneralOptions.SurveyNewsCheck; }
public async void IndexPageWhenNoItemAvailableAndForceCheck(SurveyNewsPolicy policy) { // When the user initiates the check via the menu command, // and there are no available 'not voted' items in the feed, // then the index will show. await CheckSurveyNews( MockFeeds.NoItems, policy, LastChangedDates.Get(LastChangedDates.Never), true, MockUrls.Index, UpdatedLastChangedDates.Get(UpdatedLastChangedDates.Now) ); }
internal void SyncControlWithPageSettings(NodejsGeneralOptionsPage page) { SurveyNewsCheckCombo = page.SurveyNewsCheck; _waitOnAbnormalExit.Checked = page.WaitOnAbnormalExit; _waitOnNormalExit.Checked = page.WaitOnNormalExit; _editAndContinue.Checked = page.EditAndContinue; _checkForLongPaths.Checked = page.CheckForLongPaths; _webkitDebugger.Checked = page.UseWebKitDebugger; #if !DEV15 _webkitDebugger.Enabled = false; #endif }
public async void NoPageWhenPolicyAndLastCheckDateRejected(SurveyNewsPolicy policy, int lastCheckedDate) { // When the check is done on project load in the background, // and the last check date and the policy determine the feed should NOT be retrieved, // then nothing will show. await CheckSurveyNews( MockFeeds.Items, policy, LastChangedDates.Get(lastCheckedDate), false, MockUrls.None, UpdatedLastChangedDates.Get(UpdatedLastChangedDates.Unchanged) ); }
public async void NoPageWhenNoItemAvailable(SurveyNewsPolicy policy, int expectedUpdatedLastCheckDateIndex) { // When the check is done on project load in the background, // and there are no available 'not voted' items in the feed, // then nothing will show. await CheckSurveyNews( MockFeeds.NoItems, policy, LastChangedDates.Get(LastChangedDates.MoreThanAMonth), false, MockUrls.None, UpdatedLastChangedDates.Get(expectedUpdatedLastCheckDateIndex) ); }
public async void ItemPageWhenPolicyAndLastCheckDateAccepted(SurveyNewsPolicy policy, int lastCheckedDate) { // When the check is done on project load in the background, // and the last check date and the policy determine the feed should be retrieved, // and there are available 'not voted' items in the feed, // then the first available item will show. await CheckSurveyNews( MockFeeds.Items, policy, LastChangedDates.Get(lastCheckedDate), false, MockUrls.NotVoted1, UpdatedLastChangedDates.Get(UpdatedLastChangedDates.Now) ); }
public async void ItemPageBasedOnPolicyAndNeverCheckedBefore(SurveyNewsPolicy policy, string expectedUrl, int expectedUpdatedLastCheckedDate) { // When the check is done on project load in the background, // and the last check date has never been set, // the last check date is automatically set to 4 days ago, // the policy is evaluated against the new last check date, // then the first available item will only show if once a day, otherwise nothing will show. await CheckSurveyNews( MockFeeds.Items, policy, LastChangedDates.Get(LastChangedDates.Never), false, expectedUrl, UpdatedLastChangedDates.Get(expectedUpdatedLastCheckedDate) ); }
public override void LoadSettingsFromStorage() { // Load settings from storage. _surveyNewsCheck = LoadEnum <SurveyNewsPolicy>(SurveyNewsCheckSetting) ?? SurveyNewsPolicy.CheckOnceWeek; _surveyNewsLastCheck = LoadDateTime(SurveyNewsLastCheckSetting) ?? DateTime.MinValue; _surveyNewsFeedUrl = LoadString(SurveyNewsFeedUrlSetting) ?? DefaultSurveyNewsFeedUrl; _surveyNewsIndexUrl = LoadString(SurveyNewsIndexUrlSetting) ?? DefaultSurveyNewsIndexUrl; WaitOnAbnormalExit = LoadBool(WaitOnAbnormalExitSetting) ?? true; WaitOnNormalExit = LoadBool(WaitOnNormalExitSetting) ?? false; EditAndContinue = LoadBool(EditAndContinueSetting) ?? true; CheckForLongPaths = LoadBool(CheckForLongPathsSetting) ?? true; // Synchronize UI with backing properties. if (_window != null) { _window.SyncControlWithPageSettings(this); } }
public MockSurveyNewsOptions(SurveyNewsPolicy policy, DateTime lastCheck) { this.SurveyNewsCheck = policy; this.SurveyNewsLastCheck = lastCheck; }
internal void SyncControlWithPageSettings(PythonToolsService pyService) { _showOutputWindowForVirtualEnvCreate.Checked = pyService.GeneralOptions.ShowOutputWindowForVirtualEnvCreate; _showOutputWindowForPackageInstallation.Checked = pyService.GeneralOptions.ShowOutputWindowForPackageInstallation; _elevatePip.Checked = pyService.GeneralOptions.ElevatePip; _elevateEasyInstall.Checked = pyService.GeneralOptions.ElevateEasyInstall; _autoAnalysis.Checked = pyService.GeneralOptions.AutoAnalyzeStandardLibrary; _updateSearchPathsForLinkedFiles.Checked = pyService.GeneralOptions.UpdateSearchPathsWhenAddingLinkedFiles; _unresolvedImportWarning.Checked = pyService.GeneralOptions.UnresolvedImportWarning; _clearGlobalPythonPath.Checked = pyService.GeneralOptions.ClearGlobalPythonPath; IndentationInconsistencySeverity = pyService.GeneralOptions.IndentationInconsistencySeverity; SurveyNewsCheck = pyService.GeneralOptions.SurveyNewsCheck; }
private async Task CheckSurveyNews(SurveyNewsFeed feed, SurveyNewsPolicy policy, DateTime lastChecked, bool forceCheck, string expectedNavigatedUrl, DateTime? expectedLastChecked) { string navigatedUrl = null; // Create the test objects var browser = Substitute.For<IWebBrowserServices>(); browser.When(x => x.OpenBrowser(Arg.Any<WebBrowserRole>(), Arg.Any<string>(), Arg.Any<bool>())).Do(x => { ((WebBrowserRole)x.Args()[0]).Should().Be(WebBrowserRole.News); navigatedUrl = (string)x.Args()[1]; }); var options = new MockSurveyNewsOptions(policy, lastChecked); var feedClient = new MockSurveyNewsFeedClient(feed); // Invoke the real survey/news service var service = new SurveyNewsService(feedClient, options, browser, Substitute.For<ICoreShell>()); await service.CheckSurveyNewsAsync(forceCheck); // Check that we navigated to the right url (or didn't navigate at all) navigatedUrl.Should().Be(expectedNavigatedUrl); // Check that the last checked date has been updated (or not updated at all) if (expectedLastChecked.HasValue) { var delta = options.SurveyNewsLastCheck - expectedLastChecked.Value; delta.Duration().Should().BeLessOrEqualTo(TimeSpan.FromSeconds(5)); } else { options.SurveyNewsLastCheck.Should().Be(lastChecked); } }
public override void LoadSettingsFromStorage() { // Load settings from storage. _surveyNewsCheck = LoadEnum<SurveyNewsPolicy>(SurveyNewsCheckSetting) ?? SurveyNewsPolicy.CheckOnceWeek; _surveyNewsLastCheck = LoadDateTime(SurveyNewsLastCheckSetting) ?? DateTime.MinValue; _surveyNewsFeedUrl = LoadString(SurveyNewsFeedUrlSetting) ?? DefaultSurveyNewsFeedUrl; _surveyNewsIndexUrl = LoadString(SurveyNewsIndexUrlSetting) ?? DefaultSurveyNewsIndexUrl; WaitOnAbnormalExit = LoadBool(WaitOnAbnormalExitSetting) ?? true; WaitOnNormalExit = LoadBool(WaitOnNormalExitSetting) ?? false; EditAndContinue = LoadBool(EditAndContinueSetting) ?? true; CheckForLongPaths = LoadBool(CheckForLongPathsSetting) ?? true; // Synchronize UI with backing properties. if (_window != null) { _window.SyncControlWithPageSettings(this); } }