2016-06-04 00:36:40 +00:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
|
|
|
|
using Microsoft.DotNet.Configurer;
|
|
|
|
|
using Microsoft.DotNet.Tools.Test;
|
|
|
|
|
using Microsoft.Extensions.DependencyModel.Tests;
|
|
|
|
|
using Moq;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Configurer.UnitTests
|
|
|
|
|
{
|
|
|
|
|
public class GivenADotnetFirstTimeUseConfigurer
|
|
|
|
|
{
|
2017-05-31 20:44:03 +00:00
|
|
|
|
private const string CliFallbackFolderPath = "some path";
|
|
|
|
|
|
2016-06-04 00:36:40 +00:00
|
|
|
|
private Mock<INuGetCachePrimer> _nugetCachePrimerMock;
|
2016-06-06 17:39:05 +00:00
|
|
|
|
private Mock<INuGetCacheSentinel> _nugetCacheSentinelMock;
|
2017-06-14 16:09:06 +00:00
|
|
|
|
private Mock<IFirstTimeUseNoticeSentinel> _firstTimeUseNoticeSentinelMock;
|
2017-11-10 22:47:05 +00:00
|
|
|
|
private Mock<IAspNetCertificateSentinel> _aspNetCertificateSentinelMock;
|
|
|
|
|
private Mock<IAspNetCoreCertificateGenerator> _aspNetCoreCertificateGeneratorMock;
|
2018-03-23 19:40:58 +00:00
|
|
|
|
private Mock<IFileSentinel> _toolPathSentinelMock;
|
2016-06-10 20:02:48 +00:00
|
|
|
|
private Mock<IEnvironmentProvider> _environmentProviderMock;
|
2017-06-14 16:09:06 +00:00
|
|
|
|
private Mock<IReporter> _reporterMock;
|
2018-03-23 19:40:58 +00:00
|
|
|
|
private Mock<IEnvironmentPath> _pathAdderMock;
|
2016-06-04 00:36:40 +00:00
|
|
|
|
|
|
|
|
|
public GivenADotnetFirstTimeUseConfigurer()
|
|
|
|
|
{
|
|
|
|
|
_nugetCachePrimerMock = new Mock<INuGetCachePrimer>();
|
2016-06-06 17:39:05 +00:00
|
|
|
|
_nugetCacheSentinelMock = new Mock<INuGetCacheSentinel>();
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_firstTimeUseNoticeSentinelMock = new Mock<IFirstTimeUseNoticeSentinel>();
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock = new Mock<IAspNetCertificateSentinel>();
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock = new Mock<IAspNetCoreCertificateGenerator>();
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock = new Mock<IFileSentinel>();
|
2016-06-10 20:02:48 +00:00
|
|
|
|
_environmentProviderMock = new Mock<IEnvironmentProvider>();
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_reporterMock = new Mock<IReporter>();
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock = new Mock<IEnvironmentPath>();
|
2016-06-10 20:02:48 +00:00
|
|
|
|
|
|
|
|
|
_environmentProviderMock
|
|
|
|
|
.Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", false))
|
|
|
|
|
.Returns(false);
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_environmentProviderMock
|
|
|
|
|
.Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_PRINT_TELEMETRY_MESSAGE", true))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
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,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-06-14 16:09:06 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
2017-06-21 19:44:17 +00:00
|
|
|
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage)), Times.Never);
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_reporterMock.Verify(r => r.Write(It.IsAny<string>()), Times.Never);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void It_does_not_print_the_first_time_use_notice_when_the_user_has_set_the_DOTNET_SKIP_FIRST_TIME_EXPERIENCE_environemnt_variable()
|
|
|
|
|
{
|
|
|
|
|
_firstTimeUseNoticeSentinelMock.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,
|
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-06-14 16:09:06 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
2017-06-21 19:44:17 +00:00
|
|
|
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage)), Times.Never);
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_reporterMock.Verify(r => r.Write(It.IsAny<string>()), Times.Never);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
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);
|
|
|
|
|
_environmentProviderMock
|
|
|
|
|
.Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_PRINT_TELEMETRY_MESSAGE", true))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
|
|
|
|
_nugetCachePrimerMock.Object,
|
|
|
|
|
_nugetCacheSentinelMock.Object,
|
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-06-14 16:09:06 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
2017-06-21 19:44:17 +00:00
|
|
|
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage)), Times.Never);
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_reporterMock.Verify(r => r.Write(It.IsAny<string>()), Times.Never);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void It_prints_the_telemetry_if_the_sentinel_does_not_exist()
|
|
|
|
|
{
|
|
|
|
|
_firstTimeUseNoticeSentinelMock.Setup(n => n.Exists()).Returns(false);
|
|
|
|
|
|
|
|
|
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
|
|
|
|
_nugetCachePrimerMock.Object,
|
|
|
|
|
_nugetCacheSentinelMock.Object,
|
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-06-14 16:09:06 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
2017-06-21 19:44:17 +00:00
|
|
|
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage)));
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_reporterMock.Verify(r => r.Write(It.IsAny<string>()), Times.Never);
|
2016-06-04 00:36:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void It_does_not_prime_the_cache_if_the_sentinel_exists()
|
|
|
|
|
{
|
2016-06-06 17:39:05 +00:00
|
|
|
|
_nugetCacheSentinelMock.Setup(n => n.Exists()).Returns(true);
|
2016-06-04 00:36:40 +00:00
|
|
|
|
|
|
|
|
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
|
|
|
|
_nugetCachePrimerMock.Object,
|
2016-06-10 20:02:48 +00:00
|
|
|
|
_nugetCacheSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2016-06-10 20:02:48 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
|
|
|
|
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-10 22:06:48 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
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,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-06-14 16:09:06 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
|
|
|
|
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
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,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2016-06-10 22:06:48 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
|
|
|
|
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-10 20:02:48 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
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,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2016-06-04 00:36:40 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
|
|
|
|
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void It_primes_the_cache_if_the_sentinel_does_not_exist()
|
|
|
|
|
{
|
2016-06-06 17:39:05 +00:00
|
|
|
|
_nugetCacheSentinelMock.Setup(n => n.Exists()).Returns(false);
|
2016-06-04 00:36:40 +00:00
|
|
|
|
|
|
|
|
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
|
|
|
|
_nugetCachePrimerMock.Object,
|
2016-06-10 20:02:48 +00:00
|
|
|
|
_nugetCacheSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2016-06-04 00:36:40 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
|
|
|
|
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Once);
|
2016-06-10 22:06:48 +00:00
|
|
|
|
}
|
2017-06-14 16:09:06 +00:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void It_prints_first_use_notice_and_primes_the_cache_if_the_sentinels_do_not_exist()
|
|
|
|
|
{
|
|
|
|
|
_nugetCacheSentinelMock.Setup(n => n.Exists()).Returns(false);
|
|
|
|
|
_firstTimeUseNoticeSentinelMock.Setup(n => n.Exists()).Returns(false);
|
|
|
|
|
|
|
|
|
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
|
|
|
|
_nugetCachePrimerMock.Object,
|
|
|
|
|
_nugetCacheSentinelMock.Object,
|
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-06-14 16:09:06 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
2017-06-21 19:44:17 +00:00
|
|
|
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage)));
|
|
|
|
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.NugetCachePrimeMessage)));
|
2017-06-14 16:09:06 +00:00
|
|
|
|
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Once);
|
|
|
|
|
_reporterMock.Verify(r => r.Write(It.IsAny<string>()), Times.Never);
|
|
|
|
|
}
|
2017-07-26 05:30:36 +00:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
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,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-07-26 05:30:36 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-07-26 05:30:36 +00:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-27 18:45:43 +00:00
|
|
|
|
[Fact]
|
2018-03-23 19:40:58 +00:00
|
|
|
|
public void It_adds_the_tool_path_to_the_environment_if_the_tool_path_sentinel_does_not_exist()
|
2017-11-27 18:45:43 +00:00
|
|
|
|
{
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Setup(s => s.Exists()).Returns(false);
|
2017-11-27 18:45:43 +00:00
|
|
|
|
|
|
|
|
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
|
|
|
|
_nugetCachePrimerMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_nugetCacheSentinelMock.Object,
|
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
|
|
|
|
_reporterMock.Object,
|
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-11-27 18:45:43 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Verify(s => s.Create(), Times.Once);
|
|
|
|
|
_pathAdderMock.Verify(p => p.AddPackageExecutablePathToUserPath(), Times.Once);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
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,
|
|
|
|
|
_environmentProviderMock.Object,
|
|
|
|
|
_reporterMock.Object,
|
|
|
|
|
CliFallbackFolderPath,
|
|
|
|
|
_pathAdderMock.Object);
|
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
|
|
|
|
_toolPathSentinelMock.Verify(s => s.Create(), Times.Never);
|
|
|
|
|
_pathAdderMock.Verify(p => p.AddPackageExecutablePathToUserPath(), Times.Never);
|
2017-11-27 18:45:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-26 05:30:36 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
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,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-07-26 05:30:36 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-07-26 05:30:36 +00:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
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,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-07-26 05:30:36 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
|
|
|
|
_reporterMock.Object,
|
2017-11-27 18:45:43 +00:00
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-07-26 05:30:36 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
|
|
|
|
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never);
|
|
|
|
|
}
|
2017-11-27 18:45:43 +00:00
|
|
|
|
|
2017-11-10 22:47:05 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void It_does_not_generate_the_aspnet_https_development_certificate_if_the_sentinel_exists()
|
|
|
|
|
{
|
|
|
|
|
_aspNetCertificateSentinelMock.Setup(n => n.Exists()).Returns(true);
|
|
|
|
|
|
|
|
|
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
|
|
|
|
_nugetCachePrimerMock.Object,
|
|
|
|
|
_nugetCacheSentinelMock.Object,
|
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
|
|
|
|
_reporterMock.Object,
|
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-11-10 22:47:05 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
|
|
|
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.AspNetCertificateInstalled)), Times.Never);
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Verify(s => s.GenerateAspNetCoreDevelopmentCertificate(), Times.Never);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void It_does_not_generate_the_aspnet_https_development_certificate_when_the_user_has_set_the_DOTNET_SKIP_FIRST_TIME_EXPERIENCE_environment_variable()
|
|
|
|
|
{
|
|
|
|
|
_aspNetCertificateSentinelMock.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,
|
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
|
|
|
|
_reporterMock.Object,
|
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-11-10 22:47:05 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
|
|
|
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.AspNetCertificateInstalled)), Times.Never);
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Verify(s => s.GenerateAspNetCoreDevelopmentCertificate(), Times.Never);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
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);
|
|
|
|
|
_environmentProviderMock
|
|
|
|
|
.Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", true))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
|
|
|
|
_nugetCachePrimerMock.Object,
|
|
|
|
|
_nugetCacheSentinelMock.Object,
|
|
|
|
|
_firstTimeUseNoticeSentinelMock.Object,
|
|
|
|
|
_aspNetCertificateSentinelMock.Object,
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Object,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
|
|
|
|
_reporterMock.Object,
|
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-11-10 22:47:05 +00:00
|
|
|
|
|
|
|
|
|
dotnetFirstTimeUseConfigurer.Configure();
|
|
|
|
|
|
|
|
|
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.AspNetCertificateInstalled)), Times.Never);
|
|
|
|
|
_aspNetCoreCertificateGeneratorMock.Verify(s => s.GenerateAspNetCoreDevelopmentCertificate(), Times.Never);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
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,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_toolPathSentinelMock.Object,
|
2017-11-10 22:47:05 +00:00
|
|
|
|
_environmentProviderMock.Object,
|
|
|
|
|
_reporterMock.Object,
|
|
|
|
|
CliFallbackFolderPath,
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_pathAdderMock.Object);
|
2017-11-10 22:47:05 +00:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-23 19:40:58 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void It_adds_the_tool_path_to_the_environment_if_the_first_run_experience_is_not_skipped()
|
2017-11-27 18:45:43 +00:00
|
|
|
|
{
|
2018-03-23 19:40:58 +00:00
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
_pathAdderMock.Verify(p => p.AddPackageExecutablePathToUserPath(), Times.Once);
|
2017-11-27 18:45:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-23 19:40:58 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void It_does_not_add_the_tool_path_to_the_environment_if_the_first_run_experience_is_skipped()
|
2017-11-27 18:45:43 +00:00
|
|
|
|
{
|
2018-03-23 19:40:58 +00:00
|
|
|
|
_environmentProviderMock
|
|
|
|
|
.Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", false))
|
|
|
|
|
.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();
|
|
|
|
|
|
|
|
|
|
_pathAdderMock.Verify(p => p.AddPackageExecutablePathToUserPath(), Times.Never);
|
2017-11-27 18:45:43 +00:00
|
|
|
|
}
|
2016-06-04 00:36:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|