2016-06-10 03:52:49 +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 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;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tests
|
|
|
|
|
{
|
|
|
|
|
public class GivenThatTheUserIsRunningDotNetForTheFirstTime : TestBase
|
|
|
|
|
{
|
2016-06-22 22:17:54 +00:00
|
|
|
|
private static CommandResult _firstDotnetNonVerbUseCommandResult;
|
|
|
|
|
private static CommandResult _firstDotnetVerbUseCommandResult;
|
2016-06-10 03:52:49 +00:00
|
|
|
|
private static DirectoryInfo _nugetCacheFolder;
|
|
|
|
|
|
|
|
|
|
static GivenThatTheUserIsRunningDotNetForTheFirstTime()
|
|
|
|
|
{
|
|
|
|
|
var testDirectory = TestAssetsManager.CreateTestDirectory("Dotnet_first_time_experience_tests");
|
|
|
|
|
var testNugetCache = Path.Combine(testDirectory.Path, "nuget_cache");
|
|
|
|
|
|
|
|
|
|
var command = new DotnetCommand()
|
|
|
|
|
.WithWorkingDirectory(testDirectory.Path);
|
|
|
|
|
command.Environment["NUGET_PACKAGES"] = testNugetCache;
|
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");
|
|
|
|
|
_firstDotnetVerbUseCommandResult = command.ExecuteWithCapturedOutput("new");
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
|
|
|
|
_nugetCacheFolder = new DirectoryInfo(testNugetCache);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[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
|
|
|
|
{
|
|
|
|
|
const string firstTimeNonVerbUseMessage = @".NET Command Line Tools";
|
|
|
|
|
|
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
|
|
|
|
{
|
2016-11-28 08:46:26 +00:00
|
|
|
|
string firstTimeUseWelcomeMessage = NormalizeLineEndings(@"Welcome to .NET Core!
|
2016-06-10 03:52:49 +00:00
|
|
|
|
---------------------
|
|
|
|
|
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
|
2016-12-13 22:15:35 +00:00
|
|
|
|
|
2016-06-10 03:52:49 +00:00
|
|
|
|
Telemetry
|
|
|
|
|
--------------
|
2016-12-14 03:15:22 +00:00
|
|
|
|
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.
|
2016-06-10 03:52:49 +00:00
|
|
|
|
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
|
|
|
|
|
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
|
2016-12-13 22:15:35 +00:00
|
|
|
|
|
2016-06-10 03:52:49 +00:00
|
|
|
|
Configuring...
|
|
|
|
|
-------------------
|
2016-11-28 08:46:26 +00:00
|
|
|
|
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.");
|
2016-06-10 03:52:49 +00:00
|
|
|
|
|
2016-11-14 22:26:03 +00:00
|
|
|
|
// normalizing line endings as git is occasionally replacing line endings in this file causing this test to fail
|
|
|
|
|
NormalizeLineEndings(_firstDotnetVerbUseCommandResult.StdOut)
|
2016-12-13 22:15:35 +00:00
|
|
|
|
.Should().Contain(firstTimeUseWelcomeMessage)
|
2016-11-28 08:46:26 +00:00
|
|
|
|
.And.NotContain("Restore completed in");
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2016-12-27 21:28:24 +00:00
|
|
|
|
public void ItCreatesASentinelFileUnderTheNuGetCacheFolder()
|
2016-06-22 22:17:54 +00:00
|
|
|
|
{
|
2016-08-18 22:25:16 +00:00
|
|
|
|
_nugetCacheFolder
|
|
|
|
|
.Should()
|
|
|
|
|
.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",
|
|
|
|
|
"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-01-11 06:58:30 +00:00
|
|
|
|
"microsoft.visualstudio.web.browserlink",
|
2016-12-27 21:28:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
2016-08-18 22:25:16 +00:00
|
|
|
|
_nugetCacheFolder
|
|
|
|
|
.Should()
|
2016-12-27 21:28:24 +00:00
|
|
|
|
.HaveDirectories(expectedDirectories);
|
2017-01-07 14:43:28 +00:00
|
|
|
|
|
|
|
|
|
_nugetCacheFolder
|
|
|
|
|
.GetDirectory("system.runtime")
|
|
|
|
|
.Should().HaveDirectories(new string[] { "4.1.0", "4.3.0" });
|
|
|
|
|
|
|
|
|
|
_nugetCacheFolder
|
|
|
|
|
.GetDirectory("microsoft.aspnetcore.mvc")
|
2017-01-11 06:58:30 +00:00
|
|
|
|
.Should().HaveDirectories(new string[] { "1.0.2", "1.1.0" });
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-07 14:43:28 +00:00
|
|
|
|
private string GetDotnetVersion()
|
2016-06-10 03:52:49 +00:00
|
|
|
|
{
|
|
|
|
|
return new DotnetCommand().ExecuteWithCapturedOutput("--version").StdOut
|
|
|
|
|
.TrimEnd(Environment.NewLine.ToCharArray());
|
|
|
|
|
}
|
2016-11-14 22:26:03 +00:00
|
|
|
|
|
|
|
|
|
private static string NormalizeLineEndings(string s)
|
|
|
|
|
{
|
|
|
|
|
return s.Replace("\r\n", "\n").Replace("\r", "\n");
|
|
|
|
|
}
|
2016-06-10 03:52:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|