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 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 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 ItShowsTheTelemetryNoticeWhenInvokingACommandAfterInternalReportInstallSuccessHasBeenInvoked() { var dotnetFirstTime = new DotNetFirstTime(); var command = dotnetFirstTime.Setup(Log, _testAssetsManager); command.Execute("internal-reportinstallsuccess", "test").Should().Pass(); var result = command.Execute("new", "--debug:ephemeral-hive"); var expectedVersion = GetDotnetVersion(); result.StdOut .Should() .ContainVisuallySameFragment(string.Format( Configurer.LocalizableStrings.FirstTimeMessageWelcome, DotnetFirstTimeUseConfigurer.DeriveDotnetVersionFromProductVersion(expectedVersion), expectedVersion)) .And.ContainVisuallySameFragment(Configurer.LocalizableStrings.FirstTimeMessageMoreInformation); }
public void FlagsCombinationAndAction( // Inputs bool DOTNET_GENERATE_ASPNET_CERTIFICATE, bool DOTNET_CLI_TELEMETRY_OPTOUT, // true to simulate install via installer. The first run is during installer, // silent but has sudo permission // false to simulate install via zip/tar.gz bool isFirstRunInstallerRun, // Outputs ActionCalledTime aspnetCertInstalledTimeShouldBeCalledAt, ActionCalledTime printFirstTimeWelcomeMessageShouldBeCalledAt, ActionCalledTime printTelemetryMessageShouldBeCalledAt, bool telemetryFirstRunShouldBeEnabled, bool telemetrySecondRunShouldBeEnabled ) { ResetObjectState(); _environmentProvider .Setup(p => p.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", It.IsAny <bool>())) .Returns(DOTNET_GENERATE_ASPNET_CERTIFICATE); _environmentProvider .Setup(p => p.GetEnvironmentVariableAsBool("DOTNET_CLI_TELEMETRY_OPTOUT", It.IsAny <bool>())) .Returns(DOTNET_CLI_TELEMETRY_OPTOUT); _environmentProvider .Setup(p => p.GetEnvironmentVariableAsBool("DOTNET_ADD_GLOBAL_TOOLS_TO_PATH", It.IsAny <bool>())) .Returns(true); _pathAdderMock.Setup(p => p.AddPackageExecutablePathToUserPath()).Verifiable(); // box a bool so it will be captured by reference in closure object generateAspNetCoreDevelopmentCertificateCalled = false; _aspNetCoreCertificateGeneratorMock .Setup(_ => _.GenerateAspNetCoreDevelopmentCertificate()) .Callback(() => generateAspNetCoreDevelopmentCertificateCalled = true).Verifiable(); var aspnetCertInstalledTime = new FirstRunExperienceAction( () => (bool)generateAspNetCoreDevelopmentCertificateCalled, "aspnetCertInstalledTime"); var printFirstTimeWelcomeMessage = new FirstRunExperienceAction( () => _reporterMock.Lines.Contains(string.Format( Configurer.LocalizableStrings.FirstTimeMessageWelcome, DotnetFirstTimeUseConfigurer.DeriveDotnetVersionFromProductVersion(Product.Version), Product.Version)) && _reporterMock.Lines.Contains(LocalizableStrings.FirstTimeMessageMoreInformation), "printFirstTimeWelcomeMessage"); var printTelemetryMessage = new FirstRunExperienceAction( () => _reporterMock.Lines.Contains(LocalizableStrings.TelemetryMessage), "printTelemetryMessage"); List <FirstRunExperienceAction> firstRunExperienceActions = new List <FirstRunExperienceAction>() { aspnetCertInstalledTime, printFirstTimeWelcomeMessage, printTelemetryMessage }; // First run var telemetryFirstRun = RunConfigUsingMocks(isFirstRunInstallerRun); firstRunExperienceActions.ForEach(a => a.EvaluateAfterFirstRun()); // Second run var telemetrySecondRun = RunConfigUsingMocks(false); firstRunExperienceActions.ForEach(a => a.EvaluateAfterSecondRun()); // Assertion aspnetCertInstalledTime.Assert(aspnetCertInstalledTimeShouldBeCalledAt); printFirstTimeWelcomeMessage.Assert(printFirstTimeWelcomeMessageShouldBeCalledAt); printTelemetryMessage.Assert(printTelemetryMessageShouldBeCalledAt); telemetryFirstRun.Enabled.Should().Be(telemetryFirstRunShouldBeEnabled); telemetrySecondRun.Enabled.Should().Be(telemetrySecondRunShouldBeEnabled); }