2016-06-11 13:43:56 +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 Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
using Xunit;
|
|
|
|
using FluentAssertions;
|
2016-08-27 01:14:04 +00:00
|
|
|
using System.IO;
|
2016-06-11 13:43:56 +00:00
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tests
|
|
|
|
{
|
2016-08-03 19:55:48 +00:00
|
|
|
[Collection("'dotnet test' collection")]
|
2016-06-11 13:43:56 +00:00
|
|
|
public class GivenThatIWantANewCSxUnitProject : TestBase
|
|
|
|
{
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void When_xUnit_project_created_Then_project_restores()
|
|
|
|
{
|
|
|
|
var rootPath = Temp.CreateDirectory().Path;
|
|
|
|
|
|
|
|
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
|
|
|
.Execute("new --type xunittest")
|
2016-08-27 01:14:04 +00:00
|
|
|
.Should().Pass();
|
2016-06-11 13:43:56 +00:00
|
|
|
|
|
|
|
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
|
|
|
.Execute("restore")
|
|
|
|
.Should().Pass();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void When_dotnet_test_is_invoked_Then_tests_run_without_errors()
|
|
|
|
{
|
2016-08-09 22:33:48 +00:00
|
|
|
const string testFolder = "test";
|
2016-06-11 13:43:56 +00:00
|
|
|
var rootPath = Temp.CreateDirectory().Path;
|
2016-08-09 22:33:48 +00:00
|
|
|
var testDirectory = Directory.CreateDirectory(Path.Combine(rootPath, testFolder)).FullName;
|
2016-06-11 13:43:56 +00:00
|
|
|
|
2016-08-09 22:33:48 +00:00
|
|
|
File.WriteAllText(Path.Combine(rootPath, "global.json"), $"{{ \"projects\": [\"{testFolder}\"] }}");
|
|
|
|
|
|
|
|
new TestCommand("dotnet") { WorkingDirectory = testDirectory }
|
2016-06-11 13:43:56 +00:00
|
|
|
.Execute("new --type xunittest");
|
|
|
|
|
2016-08-09 22:33:48 +00:00
|
|
|
new TestCommand("dotnet") { WorkingDirectory = testDirectory }
|
2016-06-11 13:43:56 +00:00
|
|
|
.Execute("restore");
|
|
|
|
|
|
|
|
var buildResult = new TestCommand("dotnet")
|
2016-08-09 22:33:48 +00:00
|
|
|
.WithWorkingDirectory(testDirectory)
|
2016-06-11 13:43:56 +00:00
|
|
|
.ExecuteWithCapturedOutput("test")
|
|
|
|
.Should()
|
|
|
|
.Pass()
|
|
|
|
.And
|
|
|
|
.NotHaveStdErr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|