2017-04-05 20:50:12 +00:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
2016-06-10 03:52:49 +00:00
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
|
|
|
|
using Microsoft.DotNet.Cli;
|
|
|
|
|
using Microsoft.DotNet.TestFramework;
|
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
|
using Xunit;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
|
2017-02-01 01:31:37 +00:00
|
|
|
|
[assembly: CollectionBehavior(DisableTestParallelization = true)]
|
|
|
|
|
|
2016-06-10 03:52:49 +00:00
|
|
|
|
namespace Microsoft.DotNet.Tests
|
|
|
|
|
{
|
2017-02-01 01:31:37 +00:00
|
|
|
|
public class GivenThatTheUserIsRunningDotNetForTheFirstTime : TestBase
|
2016-06-10 03:52:49 +00:00
|
|
|
|
{
|
2016-06-22 22:17:54 +00:00
|
|
|
|
private static CommandResult _firstDotnetNonVerbUseCommandResult;
|
|
|
|
|
private static CommandResult _firstDotnetVerbUseCommandResult;
|
2017-03-30 18:28:01 +00:00
|
|
|
|
private static DirectoryInfo _nugetFallbackFolder;
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
|
|
|
|
static GivenThatTheUserIsRunningDotNetForTheFirstTime()
|
|
|
|
|
{
|
2017-02-15 23:35:03 +00:00
|
|
|
|
var testDirectory = TestAssets.CreateTestDirectory("Dotnet_first_time_experience_tests");
|
2017-03-30 18:28:01 +00:00
|
|
|
|
var testNuGetHome = Path.Combine(testDirectory.FullName, "nuget_home");
|
2017-05-31 20:44:03 +00:00
|
|
|
|
var cliTestFallbackFolder = Path.Combine(testNuGetHome, ".dotnet", "NuGetFallbackFolder");
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
|
|
|
|
var command = new DotnetCommand()
|
2017-02-15 23:35:03 +00:00
|
|
|
|
.WithWorkingDirectory(testDirectory);
|
2017-03-30 18:28:01 +00:00
|
|
|
|
command.Environment["HOME"] = testNuGetHome;
|
|
|
|
|
command.Environment["USERPROFILE"] = testNuGetHome;
|
2017-04-03 17:45:35 +00:00
|
|
|
|
command.Environment["APPDATA"] = testNuGetHome;
|
2017-05-31 20:44:03 +00:00
|
|
|
|
command.Environment["DOTNET_CLI_TEST_FALLBACKFOLDER"] = cliTestFallbackFolder;
|
2016-06-14 09:41:47 +00:00
|
|
|
|
command.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "";
|
2016-10-14 07:06:35 +00:00
|
|
|
|
command.Environment["SkipInvalidConfigurations"] = "true";
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
2016-06-22 22:17:54 +00:00
|
|
|
|
_firstDotnetNonVerbUseCommandResult = command.ExecuteWithCapturedOutput("--info");
|
2017-02-01 01:31:37 +00:00
|
|
|
|
_firstDotnetVerbUseCommandResult = command.ExecuteWithCapturedOutput("new --debug:ephemeral-hive");
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
2017-05-31 20:44:03 +00:00
|
|
|
|
_nugetFallbackFolder = new DirectoryInfo(cliTestFallbackFolder);
|
2017-03-03 04:35:20 +00:00
|
|
|
|
}
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
|
|
|
|
[Fact]
|
2016-12-13 22:15:35 +00:00
|
|
|
|
public void UsingDotnetForTheFirstTimeSucceeds()
|
2016-06-10 03:52:49 +00:00
|
|
|
|
{
|
2016-08-18 22:25:16 +00:00
|
|
|
|
_firstDotnetVerbUseCommandResult
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
2016-06-22 22:17:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2016-12-13 22:15:35 +00:00
|
|
|
|
public void UsingDotnetForTheFirstTimeWithNonVerbsDoesNotPrintEula()
|
2016-06-22 22:17:54 +00:00
|
|
|
|
{
|
2017-06-13 00:31:40 +00:00
|
|
|
|
string firstTimeNonVerbUseMessage = Cli.Utils.LocalizableStrings.DotNetCommandLineTools;
|
2016-06-22 22:17:54 +00:00
|
|
|
|
|
2016-08-18 22:25:16 +00:00
|
|
|
|
_firstDotnetNonVerbUseCommandResult.StdOut
|
|
|
|
|
.Should()
|
|
|
|
|
.StartWith(firstTimeNonVerbUseMessage);
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2016-12-13 22:15:35 +00:00
|
|
|
|
public void ItShowsTheAppropriateMessageToTheUser()
|
2016-06-10 03:52:49 +00:00
|
|
|
|
{
|
2017-06-19 18:54:42 +00:00
|
|
|
|
_firstDotnetVerbUseCommandResult.StdOut
|
|
|
|
|
.Should()
|
|
|
|
|
.ContainVisuallySameFragment(Configurer.LocalizableStrings.FirstTimeWelcomeMessage)
|
|
|
|
|
.And.NotContain("Restore completed in");
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-01 01:31:37 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void ItCreatesASentinelFileUnderTheNuGetCacheFolder()
|
|
|
|
|
{
|
2017-03-30 18:28:01 +00:00
|
|
|
|
_nugetFallbackFolder
|
2016-08-18 22:25:16 +00:00
|
|
|
|
.Should()
|
2017-01-24 04:21:58 +00:00
|
|
|
|
.HaveFile($"{GetDotnetVersion()}.dotnetSentinel");
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2016-12-27 21:28:24 +00:00
|
|
|
|
public void ItRestoresTheNuGetPackagesToTheNuGetCacheFolder()
|
2016-06-10 03:52:49 +00:00
|
|
|
|
{
|
2016-12-27 21:28:24 +00:00
|
|
|
|
List<string> expectedDirectories = new List<string>()
|
|
|
|
|
{
|
|
|
|
|
"microsoft.netcore.app",
|
2017-01-27 23:46:55 +00:00
|
|
|
|
"microsoft.netcore.platforms",
|
|
|
|
|
"netstandard.library",
|
2016-12-27 21:28:24 +00:00
|
|
|
|
"microsoft.aspnetcore.diagnostics",
|
|
|
|
|
"microsoft.aspnetcore.mvc",
|
|
|
|
|
"microsoft.aspnetcore.routing",
|
|
|
|
|
"microsoft.aspnetcore.server.iisintegration",
|
|
|
|
|
"microsoft.aspnetcore.server.kestrel",
|
|
|
|
|
"microsoft.aspnetcore.staticfiles",
|
|
|
|
|
"microsoft.extensions.configuration.environmentvariables",
|
|
|
|
|
"microsoft.extensions.configuration.json",
|
|
|
|
|
"microsoft.extensions.logging",
|
|
|
|
|
"microsoft.extensions.logging.console",
|
|
|
|
|
"microsoft.extensions.logging.debug",
|
|
|
|
|
"microsoft.extensions.options.configurationextensions",
|
2017-04-22 18:52:54 +00:00
|
|
|
|
//BrowserLink has been temporarily disabled until https://github.com/dotnet/templating/issues/644 is resolved
|
|
|
|
|
//"microsoft.visualstudio.web.browserlink",
|
2016-12-27 21:28:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
2017-03-30 18:28:01 +00:00
|
|
|
|
_nugetFallbackFolder
|
2016-08-18 22:25:16 +00:00
|
|
|
|
.Should()
|
2016-12-27 21:28:24 +00:00
|
|
|
|
.HaveDirectories(expectedDirectories);
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-07 14:43:28 +00:00
|
|
|
|
private string GetDotnetVersion()
|
2017-02-01 01:31:37 +00:00
|
|
|
|
{
|
|
|
|
|
return new DotnetCommand().ExecuteWithCapturedOutput("--version").StdOut
|
|
|
|
|
.TrimEnd(Environment.NewLine.ToCharArray());
|
|
|
|
|
}
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
2017-03-03 04:35:20 +00:00
|
|
|
|
}
|