public void WhenRefWithNoCondAlreadyExistsItDoesntDuplicate()
        {
            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            new AddReferenceCommand()
            .WithWorkingDirectory(setup.TestRoot)
            .WithProject(lib.CsProjPath)
            .Execute($"\"{setup.ValidRefCsprojPath}\"")
            .Should().Pass();

            int noCondBefore = lib.CsProj().NumberOfItemGroupsWithoutCondition();
            var cmd          = new AddReferenceCommand()
                               .WithWorkingDirectory(lib.Path)
                               .WithProject(lib.CsProjName)
                               .Execute($"\"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Project already has a reference to `ValidRef\\ValidRef.csproj`.");

            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore);
            csproj.NumberOfProjectReferencesWithIncludeContaining(setup.ValidRefCsprojName).Should().Be(1);
        }
        public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
        {
            var cmd = new AddReferenceCommand().Execute(helpArg);

            cmd.Should().Pass();
            cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
        }
        public void ItCanAddRefWithoutCondAndTargetingSupersetOfFrameworksAndOneOfReferencesCompatible()
        {
            var setup = Setup();
            var lib   = new ProjDir(setup.LibDir);
            var net452netcoreapp10lib = new ProjDir(Path.Combine(setup.TestRoot, "Net452AndNetCoreApp10Lib"));

            int noCondBefore = net452netcoreapp10lib.CsProj().NumberOfItemGroupsWithoutCondition();
            var cmd          = new AddReferenceCommand()
                               .WithProject(net452netcoreapp10lib.CsProjPath)
                               .Execute($"\"{lib.CsProjPath}\"");

            cmd.Should().Pass();
            cmd.Should().Pass();
            cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ReferenceAddedToTheProject, @"..\Lib\Lib.csproj"));
            var csproj = net452netcoreapp10lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(lib.CsProjName).Should().Be(1);
        }
Exemple #4
0
        public void WhenPassedReferenceDoesNotExistItShowsAnError()
        {
            var lib = NewLibWithFrameworks();

            var contentBefore = lib.CsProjContent();
            var cmd           = new AddReferenceCommand()
                                .WithWorkingDirectory(lib.Path)
                                .WithProject(lib.CsProjName)
                                .Execute("\"IDoNotExist.csproj\"");

            cmd.Should().Fail();
            cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindProjectOrDirectory, "IDoNotExist.csproj"));
            lib.CsProjContent().Should().BeEquivalentTo(contentBefore);
        }
Exemple #5
0
        public void WhenDirectoryContainingProjectIsGivenReferenceIsAdded()
        {
            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            var result = new AddReferenceCommand()
                         .WithWorkingDirectory(setup.TestRoot)
                         .WithProject(lib.CsProjPath)
                         .Execute($"\"{Path.GetDirectoryName(setup.ValidRefCsprojPath)}\"");

            result.Should().Pass();
            result.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ReferenceAddedToTheProject, @"ValidRef\ValidRef.csproj"));
            result.StdErr.Should().BeEmpty();
        }
        public void WhenPassedReferenceDoesNotExistItShowsAnError()
        {
            var lib = NewLibWithFrameworks();

            var contentBefore = lib.CsProjContent();
            var cmd           = new AddReferenceCommand()
                                .WithWorkingDirectory(lib.Path)
                                .WithProject(lib.CsProjName)
                                .Execute("\"IDoNotExist.csproj\"");

            cmd.Should().Fail();
            cmd.StdErr.Should().Be("Reference IDoNotExist.csproj does not exist.");
            lib.CsProjContent().Should().BeEquivalentTo(contentBefore);
        }
Exemple #7
0
        public void WhenDirectoryContainsMultipleProjectsItCancelsWholeOperation()
        {
            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            var reference = "MoreThanOne";
            var result    = new AddReferenceCommand()
                            .WithWorkingDirectory(setup.TestRoot)
                            .WithProject(lib.CsProjPath)
                            .Execute(reference);

            result.Should().Fail();
            result.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
            result.StdErr.Should().Be(string.Format(CommonLocalizableStrings.MoreThanOneProjectInDirectory, reference));
        }
        public void WhenPassedMultipleRefsAndOneOfthemDoesNotExistItCancelsWholeOperation()
        {
            var lib   = NewLibWithFrameworks();
            var setup = Setup();

            var contentBefore = lib.CsProjContent();
            var cmd           = new AddReferenceCommand()
                                .WithWorkingDirectory(setup.TestRoot)
                                .WithProject(lib.CsProjPath)
                                .Execute($"\"{setup.ValidRefCsprojPath}\" \"IDoNotExist.csproj\"");

            cmd.Should().Fail();
            cmd.StdErr.Should().Be("Reference IDoNotExist.csproj does not exist.");
            lib.CsProjContent().Should().BeEquivalentTo(contentBefore);
        }
        public void WhenRefWithCondAlreadyExistsInNonUniformItemGroupItDoesntDuplicate()
        {
            var setup = Setup();
            var proj  = new ProjDir(Path.Combine(setup.TestRoot, "WithRefCondNonUniform"));

            string contentBefore = proj.CsProjContent();
            var    cmd           = new AddReferenceCommand()
                                   .WithWorkingDirectory(proj.Path)
                                   .WithProject(proj.CsProjName)
                                   .Execute($"{FrameworkNet451Arg} \"{setup.LibCsprojRelPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Project already has a reference to `..\\Lib\\Lib.csproj`.");
            proj.CsProjContent().Should().BeEquivalentTo(contentBefore);
        }
        public void WhenRefWithoutCondAlreadyExistsInNonUniformItemGroupItDoesntDuplicate()
        {
            var setup = Setup();
            var proj  = new ProjDir(Path.Combine(setup.TestRoot, "WithRefNoCondNonUniform"));

            string contentBefore = proj.CsProjContent();
            var    cmd           = new AddReferenceCommand()
                                   .WithWorkingDirectory(proj.Path)
                                   .WithProject(proj.CsProjName)
                                   .Execute($"\"{setup.LibCsprojRelPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectAlreadyHasAreference, @"..\Lib\Lib.csproj"));
            proj.CsProjContent().Should().BeEquivalentTo(contentBefore);
        }
        public void WhenFrameworkSwitchIsNotMatchingAnyOfTargetedFrameworksItPrintsError(string framework)
        {
            var setup    = Setup();
            var lib      = new ProjDir(setup.LibDir);
            var net45lib = new ProjDir(Path.Combine(setup.TestRoot, "Net45Lib"));

            var csProjContent = lib.CsProjContent();
            var cmd           = new AddReferenceCommand()
                                .WithProject(lib.CsProjPath)
                                .Execute($"-f {framework} \"{net45lib.CsProjPath}\"");

            cmd.Should().Fail();
            cmd.StdErr.Should().Be($"Project `{setup.LibCsprojPath}` does not target framework `{framework}`.");

            lib.CsProjContent().Should().BeEquivalentTo(csProjContent);
        }
        public void WhenIncompatibleFrameworkDetectedItPrintsError(string frameworkArg)
        {
            var setup    = Setup();
            var lib      = new ProjDir(setup.LibDir);
            var net45lib = new ProjDir(Path.Combine(setup.TestRoot, "Net45Lib"));

            var csProjContent = net45lib.CsProjContent();
            var cmd           = new AddReferenceCommand()
                                .WithProject(net45lib.CsProjPath)
                                .Execute($"{frameworkArg} \"{lib.CsProjPath}\"");

            cmd.Should().Fail();
            cmd.StdErr.Should().MatchRegex(ProjectNotCompatibleErrorMessageRegEx);
            cmd.StdErr.Should().MatchRegex(" - net45");
            net45lib.CsProjContent().Should().BeEquivalentTo(csProjContent);
        }
        public void ItAddsRefBetweenImports()
        {
            var lib   = NewLibWithFrameworks();
            var setup = Setup();

            var cmd = new AddReferenceCommand()
                      .WithWorkingDirectory(lib.Path)
                      .WithProject(lib.CsProjName)
                      .Execute($"\"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Reference `DotnetAddP2PProjects\\ValidRef\\ValidRef.csproj` added to the project.");
            cmd.StdErr.Should().BeEmpty();

            int state = 0;

            foreach (var el in lib.CsProj().AllChildren)
            {
                var import  = el as ProjectImportElement;
                var projRef = el as ProjectItemElement;
                switch (state)
                {
                case 0:
                    if (import != null && import.Project.EndsWith(".props"))
                    {
                        state++;
                    }
                    break;

                case 1:
                    if (projRef != null && projRef.ItemType == "ProjectReference" && projRef.Include.Contains(setup.ValidRefCsprojName))
                    {
                        state++;
                    }
                    break;

                case 2:
                    if (import != null && import.Project.EndsWith(".targets"))
                    {
                        state++;
                    }
                    break;
                }
            }

            state.Should().Be(3);
        }
        public void WhenRefWithCondAlreadyExistsInNonUniformItemGroupItAddsDifferentRefInDifferentGroup()
        {
            var setup = Setup();
            var proj  = new ProjDir(Path.Combine(setup.TestRoot, "WithRefCondNonUniform"));

            int condBefore = proj.CsProj().NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451);
            var cmd        = new AddReferenceCommand()
                             .WithWorkingDirectory(setup.TestRoot)
                             .WithProject(proj.CsProjPath)
                             .Execute($"{FrameworkNet451Arg} \"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Reference `..\\ValidRef\\ValidRef.csproj` added to the project.");
            var csproj = proj.CsProj();

            csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(condBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(setup.ValidRefCsprojName, ConditionFrameworkNet451).Should().Be(1);
        }
        public void WhenRefWithoutCondAlreadyExistsInNonUniformItemGroupItAddsDifferentRefInDifferentGroup()
        {
            var setup = Setup();
            var proj  = new ProjDir(Path.Combine(setup.TestRoot, "WithRefNoCondNonUniform"));

            int noCondBefore = proj.CsProj().NumberOfItemGroupsWithoutCondition();
            var cmd          = new AddReferenceCommand()
                               .WithWorkingDirectory(setup.TestRoot)
                               .WithProject(proj.CsProjPath)
                               .Execute($"\"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ReferenceAddedToTheProject, @"..\ValidRef\ValidRef.csproj"));
            var csproj = proj.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(setup.ValidRefCsprojName).Should().Be(1);
        }
        public void WhenProjectNameIsNotPassedItFindsItAndAddsReference()
        {
            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            int noCondBefore = lib.CsProj().NumberOfItemGroupsWithoutCondition();
            var cmd          = new AddReferenceCommand()
                               .WithWorkingDirectory(lib.Path)
                               .Execute($"\"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Reference `ValidRef\\ValidRef.csproj` added to the project.");
            cmd.StdErr.Should().BeEmpty();
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(setup.ValidRefCsprojName).Should().Be(1);
        }
        public void WhenEmptyItemGroupPresentItAddsRefInIt()
        {
            var setup = Setup();
            var proj  = new ProjDir(Path.Combine(setup.TestRoot, "EmptyItemGroup"));

            int noCondBefore = proj.CsProj().NumberOfItemGroupsWithoutCondition();
            var cmd          = new AddReferenceCommand()
                               .WithWorkingDirectory(setup.TestRoot)
                               .WithProject(proj.CsProjPath)
                               .Execute($"\"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Reference `..\\ValidRef\\ValidRef.csproj` added to the project.");
            var csproj = proj.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore);
            csproj.NumberOfProjectReferencesWithIncludeContaining(setup.ValidRefCsprojName).Should().Be(1);
        }
        public void ItCanAddReferenceWithConditionOnCompatibleFramework()
        {
            var setup    = Setup();
            var lib      = new ProjDir(setup.LibDir);
            var net45lib = new ProjDir(Path.Combine(setup.TestRoot, "Net45Lib"));

            int condBefore = lib.CsProj().NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451);
            var cmd        = new AddReferenceCommand()
                             .WithProject(lib.CsProjPath)
                             .Execute($"{FrameworkNet451Arg} \"{net45lib.CsProjPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Reference `..\\Net45Lib\\Net45Lib.csproj` added to the project.");
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(condBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(net45lib.CsProjName, ConditionFrameworkNet451).Should().Be(1);
        }
        public void WhenReferenceIsRelativeAndProjectIsNotInCurrentDirectoryReferencePathIsFixed()
        {
            var setup = Setup();
            var proj  = new ProjDir(setup.LibDir);

            int noCondBefore = proj.CsProj().NumberOfItemGroupsWithoutCondition();
            var cmd          = new AddReferenceCommand()
                               .WithWorkingDirectory(setup.TestRoot)
                               .WithProject(setup.LibCsprojPath)
                               .Execute($"\"{setup.ValidRefCsprojRelPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Reference `..\\ValidRef\\ValidRef.csproj` added to the project.");
            cmd.StdErr.Should().BeEmpty();
            var csproj = proj.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(setup.ValidRefCsprojRelToOtherProjPath.Replace('/', '\\')).Should().Be(1);
        }
        public void WhenPassedReferenceIsUsingSlashesItNormalizesItToBackslashes()
        {
            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            int noCondBefore = lib.CsProj().NumberOfItemGroupsWithoutCondition();
            var cmd          = new AddReferenceCommand()
                               .WithWorkingDirectory(lib.Path)
                               .WithProject(lib.CsProjName)
                               .Execute($"\"{setup.ValidRefCsprojPath.Replace('\\', '/')}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Reference `ValidRef\\ValidRef.csproj` added to the project.");
            cmd.StdErr.Should().BeEmpty();
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(setup.ValidRefCsprojRelPath.Replace('/', '\\')).Should().Be(1);
        }
        public void ItAddsRefWithCondAndPrintsStatus()
        {
            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            int condBefore = lib.CsProj().NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451);
            var cmd        = new AddReferenceCommand()
                             .WithWorkingDirectory(setup.TestRoot)
                             .WithProject(lib.CsProjPath)
                             .Execute($"{FrameworkNet451Arg} \"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Reference `ValidRef\\ValidRef.csproj` added to the project.");
            cmd.StdErr.Should().BeEmpty();
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(condBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(setup.ValidRefCsprojName, ConditionFrameworkNet451).Should().Be(1);
        }
        public void ItAddsRefWithoutCondAndPrintsStatus()
        {
            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            int noCondBefore = lib.CsProj().NumberOfItemGroupsWithoutCondition();
            var cmd          = new AddReferenceCommand()
                               .WithWorkingDirectory(setup.TestRoot)
                               .WithProject(lib.CsProjPath)
                               .Execute($"\"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ReferenceAddedToTheProject, @"ValidRef\ValidRef.csproj"));
            cmd.StdErr.Should().BeEmpty();
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(setup.ValidRefCsprojName).Should().Be(1);
        }
        public void WhenRefWithCondOnItemGroupAlreadyExistsItDoesntDuplicate()
        {
            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            new AddReferenceCommand()
            .WithWorkingDirectory(setup.TestRoot)
            .WithProject(lib.CsProjPath)
            .Execute($"{FrameworkNet451Arg} \"{setup.ValidRefCsprojPath}\"")
            .Should().Pass();

            var csprojContentBefore = lib.CsProjContent();
            var cmd = new AddReferenceCommand()
                      .WithWorkingDirectory(setup.TestRoot)
                      .WithProject(lib.CsProjPath)
                      .Execute($"{FrameworkNet451Arg} \"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Project already has a reference to `ValidRef\\ValidRef.csproj`.");
            lib.CsProjContent().Should().BeEquivalentTo(csprojContentBefore);
        }
        public void ItAddsMultipleRefsNoCondToTheSameItemGroup()
        {
            string OutputText = $@"{string.Format(CommonLocalizableStrings.ReferenceAddedToTheProject, @"Lib\Lib.csproj")}
{string.Format(CommonLocalizableStrings.ReferenceAddedToTheProject, @"ValidRef\ValidRef.csproj")}";

            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            int noCondBefore = lib.CsProj().NumberOfItemGroupsWithoutCondition();
            var cmd          = new AddReferenceCommand()
                               .WithWorkingDirectory(setup.TestRoot)
                               .WithProject(lib.CsProjPath)
                               .Execute($"\"{setup.LibCsprojPath}\" \"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText);
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(setup.ValidRefCsprojName).Should().Be(1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(setup.LibCsprojName).Should().Be(1);
        }
        public void ItAddsMultipleRefsWithCondToTheSameItemGroup()
        {
            const string OutputText = @"Reference `Lib\Lib.csproj` added to the project.
Reference `ValidRef\ValidRef.csproj` added to the project.";

            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            int noCondBefore = lib.CsProj().NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451);
            var cmd          = new AddReferenceCommand()
                               .WithWorkingDirectory(setup.TestRoot)
                               .WithProject(lib.CsProjPath)
                               .Execute($"{FrameworkNet451Arg}  \"{setup.LibCsprojPath}\" \"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText);
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(noCondBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(setup.ValidRefCsprojName, ConditionFrameworkNet451).Should().Be(1);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(setup.LibCsprojName, ConditionFrameworkNet451).Should().Be(1);
        }
        public void WhenRefWithCondIsPresentItAddsRefWithDifferentCond()
        {
            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            new AddReferenceCommand()
            .WithWorkingDirectory(setup.TestRoot)
            .WithProject(lib.CsProjPath)
            .Execute($"{FrameworkNetCoreApp10Arg} \"{setup.ValidRefCsprojPath}\"")
            .Should().Pass();

            int condBefore = lib.CsProj().NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451);
            var cmd        = new AddReferenceCommand()
                             .WithWorkingDirectory(setup.TestRoot)
                             .WithProject(lib.CsProjPath)
                             .Execute($"{FrameworkNet451Arg} \"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ReferenceAddedToTheProject, @"ValidRef\ValidRef.csproj"));
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(condBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(setup.ValidRefCsprojName, ConditionFrameworkNet451).Should().Be(1);
        }
        public void WhenRefWithCondIsPresentItAddsRefWithDifferentCond()
        {
            var lib   = NewLibWithFrameworks();
            var setup = Setup();

            new AddReferenceCommand()
            .WithWorkingDirectory(setup.TestRoot)
            .WithProject(lib.CsProjPath)
            .Execute($"{FrameworkNetCoreApp10Arg} \"{setup.ValidRefCsprojPath}\"")
            .Should().Pass();

            int condBefore = lib.CsProj().NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451);
            var cmd        = new AddReferenceCommand()
                             .WithWorkingDirectory(setup.TestRoot)
                             .WithProject(lib.CsProjPath)
                             .Execute($"{FrameworkNet451Arg} \"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Reference `DotnetAddP2PProjects\\ValidRef\\ValidRef.csproj` added to the project.");
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(condBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(setup.ValidRefCsprojName, ConditionFrameworkNet451).Should().Be(1);
        }
        public void WhenRefWithConditionIsPresentItAddsDifferentRefWithoutCond()
        {
            var setup = Setup();
            var lib   = NewLibWithFrameworks(dir: setup.TestRoot);

            new AddReferenceCommand()
            .WithWorkingDirectory(setup.TestRoot)
            .WithProject(lib.CsProjPath)
            .Execute($"{FrameworkNet451Arg} \"{setup.LibCsprojPath}\"")
            .Should().Pass();

            int noCondBefore = lib.CsProj().NumberOfItemGroupsWithoutCondition();
            var cmd          = new AddReferenceCommand()
                               .WithWorkingDirectory(setup.TestRoot)
                               .WithProject(lib.CsProjPath)
                               .Execute($"\"{setup.ValidRefCsprojPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Be("Reference `ValidRef\\ValidRef.csproj` added to the project.");
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore + 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(setup.ValidRefCsprojName).Should().Be(1);
        }