Esempio n. 1
0
        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("");
        }
Esempio n. 2
0
        public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
        {
            var cmd = new ListReferenceCommand(Log).Execute(helpArg);

            cmd.Should().Pass();
            cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(ListProjectReferenceCommandHelpText(Directory.GetCurrentDirectory()));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
        {
            var cmd = new ListReferenceCommand().Execute(helpArg);

            cmd.Should().Pass();
            cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
        }
Esempio n. 5
0
        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'");
        }
Esempio n. 6
0
        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")}");
        }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        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). ");
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        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));
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
        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);
        }