public void It_does_add_telemetry_when_no_firsttimeuse_values_run() { _firstTimeUseNoticeSentinelMock.Setup(n => n.Exists()).Returns(true); Dictionary <string, double> measurements = new Dictionary <string, double>(); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, new DotnetFirstRunConfiguration ( generateAspNetCertificate: false, telemetryOptout: false, addGlobalToolsToPath: false, nologo: false ), _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object, measurements); dotnetFirstTimeUseConfigurer.Configure(); measurements.Should().HaveCount(0); measurements.Should().NotContainKey("AddPackageExecutablePath Time"); measurements.Should().NotContainKey("FirstTimeUseNotice Time"); measurements.Should().NotContainKey("GenerateAspNetCertificate Time"); }
public void It_does_not_prime_the_cache_if_the_cache_sentinel_reports_Unauthorized() { _nugetCacheSentinelMock.Setup(n => n.UnauthorizedAccess).Returns(true); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, new DotnetFirstRunConfiguration ( generateAspNetCertificate: true, printTelemetryMessage: true, skipFirstRunExperience: false ), _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never); }
private static void ConfigureDotNetForFirstTimeUse( INuGetCacheSentinel nugetCacheSentinel, IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator) { using (PerfTrace.Current.CaptureTiming()) { var nugetPackagesArchiver = new NuGetPackagesArchiver(); var environmentProvider = new EnvironmentProvider(); var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true); var nugetCachePrimer = new NuGetCachePrimer( nugetPackagesArchiver, nugetCacheSentinel, cliFallbackFolderPathCalculator); var dotnetConfigurer = new DotnetFirstTimeUseConfigurer( nugetCachePrimer, nugetCacheSentinel, firstTimeUseNoticeSentinel, environmentProvider, Reporter.Output, cliFallbackFolderPathCalculator.CliFallbackFolderPath); dotnetConfigurer.Configure(); } }
private static void ConfigureDotNetForFirstTimeUse( IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, IAspNetCertificateSentinel aspNetCertificateSentinel, IFileSentinel toolPathSentinel, bool isDotnetBeingInvokedFromNativeInstaller, DotnetFirstRunConfiguration dotnetFirstRunConfiguration, IEnvironmentProvider environmentProvider, Dictionary <string, double> performanceMeasurements) { var environmentPath = EnvironmentPathFactory.CreateEnvironmentPath(isDotnetBeingInvokedFromNativeInstaller, environmentProvider); var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true); var aspnetCertificateGenerator = new AspNetCoreCertificateGenerator(); var dotnetConfigurer = new DotnetFirstTimeUseConfigurer( firstTimeUseNoticeSentinel, aspNetCertificateSentinel, aspnetCertificateGenerator, toolPathSentinel, dotnetFirstRunConfiguration, Reporter.Output, CliFolderPathCalculator.CliFallbackFolderPath, environmentPath, performanceMeasurements); dotnetConfigurer.Configure(); if (isDotnetBeingInvokedFromNativeInstaller && OperatingSystem.IsWindows()) { DotDefaultPathCorrector.Correct(); } }
public void It_generates_the_aspnet_https_development_certificate_if_the_sentinel_does_not_exist() { _aspNetCertificateSentinelMock.Setup(n => n.Exists()).Returns(false); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, new DotnetFirstRunConfiguration ( generateAspNetCertificate: true, printTelemetryMessage: true, skipFirstRunExperience: false ), _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage))); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.NugetCachePrimeMessage))); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.AspNetCertificateInstalled))); _aspNetCoreCertificateGeneratorMock.Verify(s => s.GenerateAspNetCoreDevelopmentCertificate(), Times.Once); }
public void It_prints_the_unauthorized_notice_if_the_cache_sentinel_reports_Unauthorized() { _nugetCacheSentinelMock.Setup(n => n.UnauthorizedAccess).Returns(true); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, new DotnetFirstRunConfiguration ( generateAspNetCertificate: true, printTelemetryMessage: true, skipFirstRunExperience: false ), _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage))); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == string.Format(LocalizableStrings.UnauthorizedAccessMessage, CliFallbackFolderPath)))); _reporterMock.Verify( r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.NugetCachePrimeMessage)), Times.Never); _reporterMock.Verify(r => r.Write(It.IsAny <string>()), Times.Never); }
private static void ConfigureDotNetForFirstTimeUse( IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, IAspNetCertificateSentinel aspNetCertificateSentinel, IFileSentinel toolPathSentinel, bool hasSuperUserAccess, DotnetFirstRunConfiguration dotnetFirstRunConfiguration, IEnvironmentProvider environmentProvider) { using (PerfTrace.Current.CaptureTiming()) { var environmentPath = EnvironmentPathFactory.CreateEnvironmentPath(hasSuperUserAccess, environmentProvider); var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true); var aspnetCertificateGenerator = new AspNetCoreCertificateGenerator(); var dotnetConfigurer = new DotnetFirstTimeUseConfigurer( firstTimeUseNoticeSentinel, aspNetCertificateSentinel, aspnetCertificateGenerator, toolPathSentinel, dotnetFirstRunConfiguration, Reporter.Output, CliFolderPathCalculator.CliFallbackFolderPath, environmentPath); dotnetConfigurer.Configure(); } }
public void It_does_not_prime_the_cache_if_the_sentinel_does_not_exist_but_the_user_has_set_the_DOTNET_SKIP_FIRST_TIME_EXPERIENCE_environment_variable() { _nugetCacheSentinelMock.Setup(n => n.Exists()).Returns(false); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, new DotnetFirstRunConfiguration ( generateAspNetCertificate: true, printTelemetryMessage: true, skipFirstRunExperience: true ), _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never); }
public void It_does_not_add_the_tool_path_to_the_environment_if_the_tool_path_sentinel_exists() { _toolPathSentinelMock.Setup(s => s.Exists()).Returns(true); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, new DotnetFirstRunConfiguration ( generateAspNetCertificate: true, printTelemetryMessage: true, skipFirstRunExperience: false ), _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _toolPathSentinelMock.Verify(s => s.Create(), Times.Never); _pathAdderMock.Verify(p => p.AddPackageExecutablePathToUserPath(), Times.Never); }
public void It_adds_the_tool_path_to_the_environment_if_the_tool_path_sentinel_does_not_exist() { _toolPathSentinelMock.Setup(s => s.Exists()).Returns(false); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, new DotnetFirstRunConfiguration ( generateAspNetCertificate: true, telemetryOptout: false, addGlobalToolsToPath: true, nologo: false ), _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _toolPathSentinelMock.Verify(s => s.Create(), Times.Once); _pathAdderMock.Verify(p => p.AddPackageExecutablePathToUserPath(), Times.Once); }
private static void ConfigureDotNetForFirstTimeUse( INuGetCacheSentinel nugetCacheSentinel, IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, IAspNetCertificateSentinel aspNetCertificateSentinel, CliFolderPathCalculator cliFolderPathCalculator, bool hasSuperUserAccess) { var environmentProvider = new EnvironmentProvider(); using (PerfTrace.Current.CaptureTiming()) { var nugetPackagesArchiver = new NuGetPackagesArchiver(); var environmentPath = EnvironmentPathFactory.CreateEnvironmentPath(cliFolderPathCalculator, hasSuperUserAccess, environmentProvider); var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true); var nugetCachePrimer = new NuGetCachePrimer( nugetPackagesArchiver, nugetCacheSentinel, cliFolderPathCalculator); var aspnetCertificateGenerator = new AspNetCoreCertificateGenerator(); var dotnetConfigurer = new DotnetFirstTimeUseConfigurer( nugetCachePrimer, nugetCacheSentinel, firstTimeUseNoticeSentinel, aspNetCertificateSentinel, aspnetCertificateGenerator, environmentProvider, Reporter.Output, cliFolderPathCalculator.CliFallbackFolderPath, environmentPath); dotnetConfigurer.Configure(); } }
public void It_prints_the_unauthorized_notice_if_the_cache_sentinel_reports_Unauthorized() { _nugetCacheSentinelMock.Setup(n => n.UnauthorizedAccess).Returns(true); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _environmentProviderMock.Object, _reporterMock.Object, CliFallbackFolderPath, _pathAdder.Object); dotnetFirstTimeUseConfigurer.Configure(); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage))); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == string.Format(LocalizableStrings.UnauthorizedAccessMessage, CliFallbackFolderPath)))); _reporterMock.Verify( r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.NugetCachePrimeMessage)), Times.Never); _reporterMock.Verify(r => r.Write(It.IsAny <string>()), Times.Never); }
public void It_prints_the_telemetry_if_the_sentinel_does_not_exist() { _firstTimeUseNoticeSentinelMock.Setup(n => n.Exists()).Returns(false); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, new DotnetFirstRunConfiguration ( generateAspNetCertificate: true, telemetryOptout: false, addGlobalToolsToPath: true, nologo: false ), _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str.Contains(LocalizableStrings.FirstTimeMessageMoreInformation)))); _reporterMock.Verify(r => r.Write(It.IsAny <string>()), Times.Never); }
public void ItShowsTheTelemetryNoticeWhenInvokingACommandAfterInternalReportInstallSuccessHasBeenInvoked() { var newHome = Path.Combine(_testDirectory, "new_home"); var newHomeFolder = new DirectoryInfo(Path.Combine(newHome, ".dotnet")); var profiled = Path.Combine(_testDirectory, "profile.d"); var pathsd = Path.Combine(_testDirectory, "paths.d"); var command = new DotnetCommand() .WithWorkingDirectory(_testDirectory); command.Environment["HOME"] = newHome; command.Environment["USERPROFILE"] = newHome; command.Environment["APPDATA"] = newHome; command.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = _nugetFallbackFolder.FullName; command.Environment["DOTNET_CLI_TEST_LINUX_PROFILED_PATH"] = profiled; command.Environment["DOTNET_CLI_TEST_OSX_PATHSD_PATH"] = pathsd; command.Environment["SkipInvalidConfigurations"] = "true"; command.Environment[RepoDirectoriesProvider.DotnetHomeVariableName] = ""; command.ExecuteWithCapturedOutput("internal-reportinstallsuccess test").Should().Pass(); var result = command.ExecuteWithCapturedOutput("new --debug:ephemeral-hive"); var expectedVersion = Path.GetFileName(RepoDirectoriesProvider.SdkFolderUnderTest); result.StdOut .Should() .ContainVisuallySameFragment(string.Format( Configurer.LocalizableStrings.FirstTimeMessageWelcome, DotnetFirstTimeUseConfigurer.DeriveDotnetVersionFromProductVersion(expectedVersion), expectedVersion)) .And.ContainVisuallySameFragment(Configurer.LocalizableStrings.FirstTimeMessageMoreInformation); }
public void It_generates_the_aspnet_https_development_certificate_if_the_sentinel_does_not_exist() { _aspNetCertificateSentinelMock.Setup(n => n.Exists()).Returns(false); _environmentProviderMock.Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", true)) .Returns(true); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, _environmentProviderMock.Object, _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage))); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.NugetCachePrimeMessage))); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.AspNetCertificateInstalled))); _aspNetCoreCertificateGeneratorMock.Verify(s => s.GenerateAspNetCoreDevelopmentCertificate(), Times.Once); }
public void It_prints_the_first_time_use_notice_if_the_cache_sentinel_exists_but_the_first_notice_sentinel_does_not() { _nugetCacheSentinelMock.Setup(n => n.Exists()).Returns(true); _firstTimeUseNoticeSentinelMock.Setup(n => n.Exists()).Returns(false); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, _environmentProviderMock.Object, _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage))); _reporterMock.Verify( r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.NugetCachePrimeMessage)), Times.Never); _reporterMock.Verify(r => r.Write(It.IsAny <string>()), Times.Never); }
public void It_does_not_print_the_first_time_use_notice_when_the_user_has_set_the_DOTNET_PRINT_TELEMETRY_MESSAGE_environemnt_variable() { _firstTimeUseNoticeSentinelMock.Setup(n => n.Exists()).Returns(false); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, new DotnetFirstRunConfiguration ( generateAspNetCertificate: true, printTelemetryMessage: false, skipFirstRunExperience: false ), _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage)), Times.Never); _reporterMock.Verify(r => r.Write(It.IsAny <string>()), Times.Never); }
public void It_does_not_prime_the_cache_if_first_run_experience_is_already_happening() { _nugetCacheSentinelMock.Setup(n => n.InProgressSentinelAlreadyExists()).Returns(true); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, new DotnetFirstRunConfiguration ( generateAspNetCertificate: true, printTelemetryMessage: true, skipFirstRunExperience: false ), _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never); }
private static void ConfigureDotNetForFirstTimeUse( IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, IAspNetCertificateSentinel aspNetCertificateSentinel, IFileSentinel toolPathSentinel, bool isDotnetBeingInvokedFromNativeInstaller, DotnetFirstRunConfiguration dotnetFirstRunConfiguration, IEnvironmentProvider environmentProvider) { using (PerfTrace.Current.CaptureTiming()) { var environmentPath = EnvironmentPathFactory.CreateEnvironmentPath(isDotnetBeingInvokedFromNativeInstaller, environmentProvider); var commandFactory = new DotNetCommandFactory(alwaysRunOutOfProc: true); var aspnetCertificateGenerator = new AspNetCoreCertificateGenerator(); var dotnetConfigurer = new DotnetFirstTimeUseConfigurer( firstTimeUseNoticeSentinel, aspNetCertificateSentinel, aspnetCertificateGenerator, toolPathSentinel, dotnetFirstRunConfiguration, Reporter.Output, CliFolderPathCalculator.CliFallbackFolderPath, environmentPath); dotnetConfigurer.Configure(); if (isDotnetBeingInvokedFromNativeInstaller && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { DotDefaultPathCorrector.Correct(); } } }
public void It_does_not_generate_the_aspnet_https_development_certificate_when_the_user_has_set_the_DOTNET_GENERATE_ASPNET_CERTIFICATE_environment_variable() { _aspNetCertificateSentinelMock.Setup(n => n.Exists()).Returns(false); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _aspNetCertificateSentinelMock.Object, _aspNetCoreCertificateGeneratorMock.Object, _toolPathSentinelMock.Object, new DotnetFirstRunConfiguration ( generateAspNetCertificate: false, printTelemetryMessage: true, skipFirstRunExperience: false ), _reporterMock.Object, CliFallbackFolderPath, _pathAdderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.AspNetCertificateInstalled)), Times.Never); _aspNetCoreCertificateGeneratorMock.Verify(s => s.GenerateAspNetCoreDevelopmentCertificate(), Times.Never); }
private Telemetry RunConfigUsingMocks(bool isInstallerRun) { // Assume the following objects set up are in sync with production behavior. // subject to future refactoring to de-dup with production code. var _environmentProviderObject = _environmentProvider.Object; bool generateAspNetCertificate = _environmentProviderObject.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", true); bool skipFirstRunExperience = _environmentProviderObject.GetEnvironmentVariableAsBool("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", false); bool telemetryOptout = _environmentProviderObject.GetEnvironmentVariableAsBool("DOTNET_CLI_TELEMETRY_OPTOUT", false); IAspNetCertificateSentinel aspNetCertificateSentinel; IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel; IFileSentinel toolPathSentinel; if (isInstallerRun) { aspNetCertificateSentinel = new NoOpAspNetCertificateSentinel(); firstTimeUseNoticeSentinel = new NoOpFirstTimeUseNoticeSentinel(); toolPathSentinel = new NoOpFileSentinel(exists: false); // When running through a native installer, we want the cache expansion to happen, so // we need to override this. skipFirstRunExperience = false; } else { aspNetCertificateSentinel = _aspNetCertificateSentinelMock; firstTimeUseNoticeSentinel = _firstTimeUseNoticeSentinelMock; toolPathSentinel = _toolPathSentinelMock; } var configurer = new DotnetFirstTimeUseConfigurer( firstTimeUseNoticeSentinel: firstTimeUseNoticeSentinel, aspNetCertificateSentinel: aspNetCertificateSentinel, aspNetCoreCertificateGenerator: _aspNetCoreCertificateGeneratorMock.Object, toolPathSentinel: toolPathSentinel, dotnetFirstRunConfiguration: new DotnetFirstRunConfiguration ( generateAspNetCertificate: generateAspNetCertificate, skipFirstRunExperience: skipFirstRunExperience, telemetryOptout: telemetryOptout ), reporter: _reporterMock, cliFallbackFolderPath: CliFallbackFolderPath, pathAdder: _pathAdderMock.Object); configurer.Configure(); return(new Telemetry(firstTimeUseNoticeSentinel, "test", environmentProvider: _environmentProviderObject, senderCount: 0)); }
private Telemetry RunConfigUsingMocks(bool isInstallerRun) { // Assume the following objects set up are in sync with production behavior. // subject to future refactoring to de-dup with production code. var _environmentProviderObject = _environmentProvider.Object; bool generateAspNetCertificate = _environmentProviderObject.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", true); bool telemetryOptout = _environmentProviderObject.GetEnvironmentVariableAsBool("DOTNET_CLI_TELEMETRY_OPTOUT", false); bool addGlobalToolsToPath = _environmentProviderObject.GetEnvironmentVariableAsBool("DOTNET_ADD_GLOBAL_TOOLS_TO_PATH", defaultValue: true); bool nologo = _environmentProviderObject.GetEnvironmentVariableAsBool("DOTNET_NOLOGO", defaultValue: false); IAspNetCertificateSentinel aspNetCertificateSentinel; IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel; IFileSentinel toolPathSentinel; if (isInstallerRun) { aspNetCertificateSentinel = new NoOpAspNetCertificateSentinel(); firstTimeUseNoticeSentinel = new NoOpFirstTimeUseNoticeSentinel(); toolPathSentinel = new NoOpFileSentinel(exists: false); } else { aspNetCertificateSentinel = _aspNetCertificateSentinelMock; firstTimeUseNoticeSentinel = _firstTimeUseNoticeSentinelMock; toolPathSentinel = _toolPathSentinelMock; } var configurer = new DotnetFirstTimeUseConfigurer( firstTimeUseNoticeSentinel: firstTimeUseNoticeSentinel, aspNetCertificateSentinel: aspNetCertificateSentinel, aspNetCoreCertificateGenerator: _aspNetCoreCertificateGeneratorMock.Object, toolPathSentinel: toolPathSentinel, dotnetFirstRunConfiguration: new DotnetFirstRunConfiguration ( generateAspNetCertificate: generateAspNetCertificate, telemetryOptout: telemetryOptout, addGlobalToolsToPath: addGlobalToolsToPath, nologo: nologo ), reporter: _reporterMock, cliFallbackFolderPath: CliFallbackFolderPath, pathAdder: _pathAdderMock.Object); configurer.Configure(); return(new Telemetry(firstTimeUseNoticeSentinel, "test", environmentProvider: _environmentProviderObject, senderCount: 0)); }
public void ItShowsTheAppropriateMessageToTheUser() { var expectedVersion = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "ExpectedSdkVersion.txt")); _firstDotnetVerbUseCommandResult.StdOut .Should() .ContainVisuallySameFragment(string.Format( Configurer.LocalizableStrings.FirstTimeMessageWelcome, DotnetFirstTimeUseConfigurer.DeriveDotnetVersionFromProductVersion(expectedVersion), expectedVersion)) .And.ContainVisuallySameFragment(Configurer.LocalizableStrings.FirstTimeMessageMoreInformation) .And.NotContain("Restore completed in"); }
public void ItShowsTheAppropriateMessageToTheUser() { var expectedVersion = GetDotnetVersion(); _fixture.FirstDotnetVerbUseCommandResult.StdOut .Should() .ContainVisuallySameFragment(string.Format( Configurer.LocalizableStrings.FirstTimeMessageWelcome, DotnetFirstTimeUseConfigurer.DeriveDotnetVersionFromProductVersion(expectedVersion), expectedVersion)) .And.ContainVisuallySameFragment(Configurer.LocalizableStrings.FirstTimeMessageMoreInformation) .And.NotContain("Restore completed in"); }
public void It_primes_the_cache_if_the_sentinel_does_not_exist() { _nugetCacheSentinelMock.Setup(n => n.Exists()).Returns(false); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _environmentProviderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Once); }
public void It_does_not_prime_the_cache_if_first_run_experience_is_already_happening() { _nugetCacheSentinelMock.Setup(n => n.InProgressSentinelAlreadyExists()).Returns(true); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _environmentProviderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never); }
public void It_does_not_prime_the_cache_if_the_cache_sentinel_reports_Unauthorized() { _nugetCacheSentinelMock.Setup(n => n.UnauthorizedAccess).Returns(true); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _environmentProviderMock.Object, _reporterMock.Object, CliFallbackFolderPath); dotnetFirstTimeUseConfigurer.Configure(); _nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never); }
public void It_does_not_prime_the_cache_if_the_sentinel_exists_but_the_user_has_set_the_DOTNET_SKIP_FIRST_TIME_EXPERIENCE_environemnt_variable() { _nugetCacheSentinelMock.Setup(n => n.Exists()).Returns(false); _environmentProviderMock .Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", false)) .Returns(true); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _environmentProviderMock.Object); dotnetFirstTimeUseConfigurer.Configure(); _nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never); }
public void It_does_not_prime_the_cache_if_cache_is_missing() { _nugetCachePrimerMock.Setup(n => n.SkipPrimingTheCache()).Returns(true); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _environmentProviderMock.Object, _reporterMock.Object, CliFallbackFolderPath, _pathAdder.Object); dotnetFirstTimeUseConfigurer.Configure(); _nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never); }
public void It_does_not_print_the_first_time_use_notice_if_the_sentinel_exists() { _firstTimeUseNoticeSentinelMock.Setup(n => n.Exists()).Returns(true); var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer( _nugetCachePrimerMock.Object, _nugetCacheSentinelMock.Object, _firstTimeUseNoticeSentinelMock.Object, _environmentProviderMock.Object, _reporterMock.Object, CliFallbackFolderPath); dotnetFirstTimeUseConfigurer.Configure(); _reporterMock.Verify(r => r.WriteLine(It.Is <string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage)), Times.Never); _reporterMock.Verify(r => r.Write(It.IsAny <string>()), Times.Never); }