public void WhenBrokenProjectIsPassedItPrintsError() { string projName = "Broken/Broken.csproj"; var setup = Setup(); string brokenFolder = Path.Combine(setup.TestRoot, "Broken"); Directory.CreateDirectory(brokenFolder); string brokenProjectPath = Path.Combine(brokenFolder, "Broken.csproj"); File.WriteAllText(brokenProjectPath, $@"<Project Sdk=""Microsoft.NET.Sdk"" ToolsVersion=""15.0"" xmlns=""http://schemas.microsoft.com/developer/msbuild/2003""> <PropertyGroup> <OutputType>Library</OutputType> <TargetFrameworks>net451;{ToolsetInfo.CurrentTargetFramework}</TargetFrameworks> </PropertyGroup> <ItemGroup> <Compile Include=""**\*.cs""/> <EmbeddedResource Include=""**\*.resx""/> <!--intentonally broken-->"); var cmd = new ListReferenceCommand(Log) .WithProject(projName) .WithWorkingDirectory(setup.TestRoot) .Execute(setup.ValidRefCsprojPath); cmd.ExitCode.Should().NotBe(0); cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.ProjectIsInvalid, projName)); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(""); }
public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg) { var cmd = new ListReferenceCommand(Log).Execute(helpArg); cmd.Should().Pass(); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(ListProjectReferenceCommandHelpText(Directory.GetCurrentDirectory())); }
public void ItPrintsMultipleReferences() { string OutputText = CommonLocalizableStrings.ProjectReferenceOneOrMore; OutputText += $@" {new string('-', OutputText.Length)} ..\ref1\ref1.csproj ..\ref2\ref2.csproj ..\ref3\ref3.csproj"; var lib = NewLib("lib"); string ref1 = NewLib("ref1").CsProjPath; string ref2 = NewLib("ref2").CsProjPath; string ref3 = NewLib("ref3").CsProjPath; AddValidRef(ref1, lib); AddValidRef(ref2, lib); AddValidRef(ref3, lib); var cmd = new ListReferenceCommand() .WithProject(lib.CsProjPath) .Execute(); cmd.Should().Pass(); cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText); }
public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg) { var cmd = new ListReferenceCommand().Execute(helpArg); cmd.Should().Pass(); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText); }
public void WhenTooManyArgumentsArePassedItPrintsError() { var cmd = new ListReferenceCommand() .WithProject("one two three") .Execute("proj.csproj"); cmd.ExitCode.Should().NotBe(0); cmd.StdErr.Should().BeVisuallyEquivalentTo( "Unrecognized command or argument 'two'\r\nUnrecognized command or argument 'three'"); }
public void WhenTooManyArgumentsArePassedItPrintsError() { var cmd = new ListReferenceCommand() .WithProject("one two three") .Execute("proj.csproj"); cmd.ExitCode.Should().NotBe(0); cmd.StdErr.Should().BeVisuallyEquivalentTo($@"{string.Format(CommandLine.LocalizableStrings.UnrecognizedCommandOrArgument, "two")} {string.Format(CommandLine.LocalizableStrings.UnrecognizedCommandOrArgument, "three")}"); }
public void WhenNoProjectReferencesArePresentInTheProjectItPrintsError() { var lib = NewLib(); var cmd = new ListReferenceCommand() .WithProject(lib.CsProjPath) .Execute(); cmd.Should().Pass(); cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.NoReferencesFound, CommonLocalizableStrings.P2P, lib.CsProjPath)); }
public void WhenNoProjectReferencesArePresentInTheProjectItPrintsError() { var lib = NewLib(); var cmd = new ListReferenceCommand() .WithProject(lib.CsProjPath) .Execute(); cmd.Should().Pass(); cmd.StdOut.Should().Be($"There are no Project to Project references in project {lib.CsProjPath}. ;; Project to Project is the type of the item being requested (project, package, p2p) and {lib.CsProjPath} is the object operated on (a project file or a solution file). "); }
public void WhenNoProjectsExistsInTheDirectoryItPrintsErrorAndUsage() { var setup = Setup(); var cmd = new ListReferenceCommand() .WithWorkingDirectory(setup.TestRoot) .Execute($"\"{setup.ValidRefCsprojPath}\""); cmd.ExitCode.Should().NotBe(0); cmd.StdErr.Should().Be($"Could not find any project in `{setup.TestRoot + Path.DirectorySeparatorChar}`."); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); }
public void WhenNoProjectsExistsInTheDirectoryItPrintsErrorAndUsage() { var setup = Setup(); var cmd = new ListReferenceCommand() .WithWorkingDirectory(setup.TestRoot) .Execute($"\"{setup.ValidRefCsprojPath}\""); cmd.ExitCode.Should().NotBe(0); cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindAnyProjectInDirectory, setup.TestRoot + Path.DirectorySeparatorChar)); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText); }
public void WhenMoreThanOneProjectExistsInTheDirectoryItPrintsErrorAndUsage() { var setup = Setup(); var workingDir = Path.Combine(setup.TestRoot, "MoreThanOne"); var cmd = new ListReferenceCommand() .WithWorkingDirectory(workingDir) .Execute($"\"{setup.ValidRefCsprojRelToOtherProjPath}\""); cmd.ExitCode.Should().NotBe(0); cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.MoreThanOneProjectInDirectory, workingDir + Path.DirectorySeparatorChar)); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText); }
public void WhenMoreThanOneProjectExistsInTheDirectoryItPrintsErrorAndUsage() { var setup = Setup(); var workingDir = Path.Combine(setup.TestRoot, "MoreThanOne"); var cmd = new ListReferenceCommand() .WithWorkingDirectory(workingDir) .Execute($"\"{setup.ValidRefCsprojRelToOtherProjPath}\""); cmd.ExitCode.Should().NotBe(0); cmd.StdErr.Should().Be($"Found more than one project in `{workingDir + Path.DirectorySeparatorChar}`. Please specify which one to use."); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); }
public void WhenNonExistingProjectIsPassedItPrintsErrorAndUsage(string projName) { var setup = Setup(); var cmd = new ListReferenceCommand() .WithWorkingDirectory(setup.TestRoot) .WithProject(projName) .Execute($"\"{setup.ValidRefCsprojPath}\""); cmd.ExitCode.Should().NotBe(0); cmd.StdErr.Should().Be($"Could not find project or directory `{projName}`."); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); }
public void WhenNonExistingProjectIsPassedItPrintsErrorAndUsage(string projName) { var setup = Setup(); var cmd = new ListReferenceCommand() .WithWorkingDirectory(setup.TestRoot) .WithProject(projName) .Execute($"\"{setup.ValidRefCsprojPath}\""); cmd.ExitCode.Should().NotBe(0); cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindProjectOrDirectory, projName)); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText); }
public void WhenBrokenProjectIsPassedItPrintsErrorAndUsage() { string projName = "Broken/Broken.csproj"; var setup = Setup(); var cmd = new ListReferenceCommand(Log) .WithProject(projName) .WithWorkingDirectory(setup.TestRoot) .Execute(setup.ValidRefCsprojPath); cmd.ExitCode.Should().NotBe(0); cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.ProjectIsInvalid, "Broken/Broken.csproj")); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(ListProjectReferenceCommandHelpText(setup.TestRoot)); }
public void WhenBrokenProjectIsPassedItPrintsErrorAndUsage() { string projName = "Broken/Broken.csproj"; var setup = Setup(); var cmd = new ListReferenceCommand() .WithWorkingDirectory(setup.TestRoot) .WithProject(projName) .Execute($"\"{setup.ValidRefCsprojPath}\""); cmd.ExitCode.Should().NotBe(0); cmd.StdErr.Should().Be("Project `Broken/Broken.csproj` is invalid."); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); }
public void ItPrintsSingleReference() { const string OutputText = @"Project reference(s) -------------------- ..\ref\ref.csproj"; var lib = NewLib("lib"); string ref1 = NewLib("ref").CsProjPath; AddValidRef(ref1, lib); var cmd = new ListReferenceCommand() .WithProject(lib.CsProjPath) .Execute(); cmd.Should().Pass(); cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText); }
public void ItPrintsSingleReference() { string OutputText = CommonLocalizableStrings.ProjectReferenceOneOrMore; OutputText += $@" {new string('-', OutputText.Length)} ..\ref\ref.csproj"; var testDirectory = _testAssetsManager.CreateTestDirectory().Path; var lib = NewLib(testDirectory, "lib"); string ref1 = NewLib(testDirectory, "ref").CsProjPath; AddValidRef(ref1, lib); var cmd = new ListReferenceCommand(Log) .WithProject(lib.CsProjPath) .Execute(); cmd.Should().Pass(); cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText); }
public void ItPrintsMultipleReferences() { const string OutputText = @"Project reference(s) -------------------- ..\ItPrintsSingleReferenceref1\ItPrintsSingleReferenceref1.csproj ..\ItPrintsSingleReferenceref2\ItPrintsSingleReferenceref2.csproj ..\ItPrintsSingleReferenceref3\ItPrintsSingleReferenceref3.csproj"; var lib = NewLib("ItPrintsSingleReference", "lib"); string ref1 = NewLib("ItPrintsSingleReference", "ref1").CsProjPath; string ref2 = NewLib("ItPrintsSingleReference", "ref2").CsProjPath; string ref3 = NewLib("ItPrintsSingleReference", "ref3").CsProjPath; AddValidRef(ref1, lib); AddValidRef(ref2, lib); AddValidRef(ref3, lib); var cmd = new ListReferenceCommand() .WithProject(lib.CsProjPath) .Execute(); cmd.Should().Pass(); cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText); }