add some test cases stubs

This commit is contained in:
Krzysztof Wicher 2016-11-29 16:14:05 -08:00
parent 65f699f1cc
commit 23b46490a3
2 changed files with 139 additions and 1 deletions

View file

@ -0,0 +1,29 @@
// 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.Cli.Utils;
namespace Microsoft.DotNet.Tools.Test.Utilities
{
public sealed class RemoveP2PCommand : TestCommand
{
private string _projectName = null;
public RemoveP2PCommand()
: base("dotnet")
{
}
public override CommandResult Execute(string args = "")
{
args = $"remove {_projectName} p2p {args}";
return base.ExecuteWithCapturedOutput(args);
}
public RemoveP2PCommand WithProject(string projectName)
{
_projectName = projectName;
return this;
}
}
}

View file

@ -52,8 +52,117 @@ namespace Microsoft.DotNet.Cli.Remove.P2P.Tests
return dir;
}
[Theory]
[InlineData("--help")]
[InlineData("-h")]
public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
{
var cmd = new RemoveP2PCommand().Execute(helpArg);
cmd.Should().Pass();
cmd.StdOut.Should().Contain("Usage");
}
[Theory]
[InlineData("idontexist.csproj")]
[InlineData("ihave?inv@lid/char\\acters")]
public void WhenNonExistingProjectIsPassedItPrintsErrorAndUsage(string projName)
{
var setup = Setup();
var cmd = new RemoveP2PCommand()
.WithWorkingDirectory(setup.TestRoot)
.WithProject(projName)
.Execute($"\"{setup.ValidRefCsprojPath}\"");
cmd.ExitCode.Should().NotBe(0);
cmd.StdErr.Should().Contain("Could not find");
cmd.StdOut.Should().Contain("Usage");
}
[Fact]
public void FinishMe()
public void WhenBrokenProjectIsPassedItPrintsErrorAndUsage()
{
string projName = "Broken/Broken.csproj";
var setup = Setup();
var cmd = new RemoveP2PCommand()
.WithWorkingDirectory(setup.TestRoot)
.WithProject(projName)
.Execute($"\"{setup.ValidRefCsprojPath}\"");
cmd.ExitCode.Should().NotBe(0);
cmd.StdErr.Should().Contain("Invalid project");
cmd.StdOut.Should().Contain("Usage");
}
[Fact]
public void WhenMoreThanOneProjectExistsInTheDirectoryItPrintsErrorAndUsage()
{
var setup = Setup();
var cmd = new RemoveP2PCommand()
.WithWorkingDirectory(Path.Combine(setup.TestRoot, "MoreThanOne"))
.Execute($"\"{setup.ValidRefCsprojRelToOtherProjPath}\"");
cmd.ExitCode.Should().NotBe(0);
cmd.StdErr.Should().Contain("more than one");
cmd.StdOut.Should().Contain("Usage");
}
[Fact]
public void WhenNoProjectsExistsInTheDirectoryItPrintsErrorAndUsage()
{
var setup = Setup();
var cmd = new RemoveP2PCommand()
.WithWorkingDirectory(setup.TestRoot)
.Execute($"\"{setup.ValidRefCsprojPath}\"");
cmd.ExitCode.Should().NotBe(0);
cmd.StdErr.Should().Contain("not find any");
cmd.StdOut.Should().Contain("Usage");
}
[Fact]
public void ItRemovesRefWithoutCondAndPrintsStatus()
{
throw new NotImplementedException();
}
[Fact]
public void ItRemovesRefWithConAndPrintsStatus()
{
throw new NotImplementedException();
}
[Fact]
public void WhenTwoRefsArePresentItDoesNotRemoveBoth()
{
throw new NotImplementedException();
}
[Fact]
public void WhenRefWithoutCondIsNotThereItPrintsMessage()
{
throw new NotImplementedException();
}
[Fact]
public void WhenRefWithCondIsNotThereItPrintsMessage()
{
throw new NotImplementedException();
}
[Fact]
public void WhenRefWithCondIsPresentAndRemovingNoCondItDoesNotRemoveIt()
{
throw new NotImplementedException();
}
[Fact]
public void WhenRefWithoutCondIsPresentAndRemovingRefWithCondItDoesNotRemoveIt()
{
throw new NotImplementedException();
}
[Fact]
public void WhenRefWithDifferentCondIsPresentItDoesNotRemoveIt()
{
throw new NotImplementedException();
}