Ejemplo n.º 1
0
        public void WhenRefWithAndWithoutCondArePresentAndRemovingNoCondItDoesNotRemoveOther()
        {
            var lib          = NewLib();
            var setup        = Setup();
            var librefCond   = AddLibRef(setup, lib, FrameworkNet451Arg);
            var librefNoCond = AddLibRef(setup, lib);

            var csprojBefore = lib.CsProj();
            int noCondBefore = csprojBefore.NumberOfItemGroupsWithoutCondition();
            int condBefore   = csprojBefore.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451);
            var cmd          = new RemoveP2PCommand()
                               .WithWorkingDirectory(setup.TestRoot)
                               .WithProject(lib.CsProjPath)
                               .Execute($"\"{librefNoCond.CsProjPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().MatchRegex("(^|[\r\n])Project reference[^\r\n]*removed.($|[\r\n])");
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(librefNoCond.Name).Should().Be(0);

            csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(condBefore);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(librefCond.Name, ConditionFrameworkNet451).Should().Be(1);
        }
Ejemplo n.º 2
0
        public void WhenRefWithDifferentCondIsPresentItDoesNotRemoveIt()
        {
            var lib                    = NewLib();
            var setup                  = Setup();
            var librefCondNet451       = AddLibRef(setup, lib, FrameworkNet451Arg);
            var librefCondNetCoreApp10 = AddLibRef(setup, lib, FrameworkNetCoreApp10Arg);

            var csprojBefore           = lib.CsProj();
            int condNet451Before       = csprojBefore.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451);
            int condNetCoreApp10Before = csprojBefore.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNetCoreApp10);
            var cmd = new RemoveP2PCommand()
                      .WithWorkingDirectory(setup.TestRoot)
                      .WithProject(lib.CsProjPath)
                      .Execute($"{FrameworkNet451Arg} \"{librefCondNet451.CsProjPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().MatchRegex("(^|[\r\n])Project reference[^\r\n]*removed.($|[\r\n])");
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(condNet451Before - 1);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(librefCondNet451.Name, ConditionFrameworkNet451).Should().Be(0);

            csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNetCoreApp10).Should().Be(condNetCoreApp10Before);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(librefCondNetCoreApp10.Name, ConditionFrameworkNetCoreApp10).Should().Be(1);
        }
Ejemplo n.º 3
0
        public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
        {
            var cmd = new RemoveP2PCommand().Execute(helpArg);

            cmd.Should().Pass();
            cmd.StdOut.Should().Contain("Usage");
        }
Ejemplo n.º 4
0
        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");
        }
Ejemplo n.º 5
0
        public void WhenNoProjectsExistsInTheDirectoryItPrintsErrorAndUsage()
        {
            var setup = Setup();

            var cmd = new RemoveP2PCommand()
                      .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().Be(HelpText);
        }
Ejemplo n.º 6
0
        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");
        }
Ejemplo n.º 7
0
        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");
        }
Ejemplo n.º 8
0
        public void WhenMoreThanOneProjectExistsInTheDirectoryItPrintsErrorAndUsage()
        {
            var setup = Setup();

            var workingDir = Path.Combine(setup.TestRoot, "MoreThanOne");
            var cmd        = new RemoveP2PCommand()
                             .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().Be(HelpText);
        }
Ejemplo n.º 9
0
        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");
        }
Ejemplo n.º 10
0
        public void WhenRefWithCondIsNotThereItPrintsMessage()
        {
            var lib    = NewLib();
            var setup  = Setup();
            var libref = GetLibRef(setup);

            string csprojContetntBefore = lib.CsProjContent();
            var    cmd = new RemoveP2PCommand()
                         .WithWorkingDirectory(setup.TestRoot)
                         .WithProject(lib.CsProjPath)
                         .Execute($"{FrameworkNet451Arg} \"{libref.CsProjPath}\"");

            cmd.Should().Pass();
            cmd.StdOut.Should().Contain("could not be found");
            lib.CsProjContent().Should().BeEquivalentTo(csprojContetntBefore);
        }
Ejemplo n.º 11
0
        public void ItRemovesRefWithCondAndPrintsStatus()
        {
            var lib    = NewLibWithFrameworks();
            var setup  = Setup();
            var libref = AddLibRef(setup, lib, FrameworkNet451Arg);

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

            cmd.Should().Pass();
            cmd.StdOut.Should().Be($"Project reference `{Path.Combine(TestSetup.ProjectName, "Lib", setup.LibCsprojName)}` removed.");
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(condBefore - 1);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(libref.Name, ConditionFrameworkNet451).Should().Be(0);
        }
Ejemplo n.º 12
0
        public void WhenPassingRefWithAbsolutePathItRemovesRefWithRelPath()
        {
            var setup  = Setup();
            var lib    = GetLibRef(setup);
            var libref = AddValidRef(setup, lib);

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

            cmd.Should().Pass();
            cmd.StdOut.Should().MatchRegex("(^|[\r\n])Project reference[^\r\n]*removed.($|[\r\n])");
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(libref.Name).Should().Be(0);
        }
Ejemplo n.º 13
0
        public void ItRemovesRefWithCondAndPrintsStatus()
        {
            var lib    = NewLib();
            var setup  = Setup();
            var libref = AddLibRef(setup, lib, FrameworkNet451Arg);

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

            cmd.Should().Pass();
            cmd.StdOut.Should().MatchRegex("(^|[\r\n])Project reference[^\r\n]*removed.($|[\r\n])");
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(condBefore - 1);
            csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(libref.Name, ConditionFrameworkNet451).Should().Be(0);
        }
Ejemplo n.º 14
0
        public void WhenDuplicateReferencesArePresentItRemovesThemAll()
        {
            var setup  = Setup();
            var proj   = new ProjDir(Path.Combine(setup.TestRoot, "WithDoubledRef"));
            var libref = GetLibRef(setup);

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

            cmd.Should().Pass();
            cmd.StdOut.Should().MatchRegex("(^|[\r\n])Project reference[^\r\n]*removed.($|[\r\n])");

            var csproj = proj.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(libref.Name).Should().Be(0);
        }
Ejemplo n.º 15
0
        public void WhenTwoDifferentRefsArePresentItDoesNotRemoveBoth()
        {
            var lib      = NewLibWithFrameworks();
            var setup    = Setup();
            var libref   = AddLibRef(setup, lib);
            var validref = AddValidRef(setup, lib);

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

            cmd.Should().Pass();
            cmd.StdOut.Should().Be($"Project reference `{Path.Combine(TestSetup.ProjectName, "Lib", setup.LibCsprojName)}` removed.");
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore);
            csproj.NumberOfProjectReferencesWithIncludeContaining(libref.Name).Should().Be(0);
        }
Ejemplo n.º 16
0
        public void WhenTwoDifferentRefsArePresentItDoesNotRemoveBoth()
        {
            var lib      = NewLib();
            var setup    = Setup();
            var libref   = AddLibRef(setup, lib);
            var validref = AddValidRef(setup, lib);

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

            cmd.Should().Pass();
            cmd.StdOut.Should().MatchRegex("(^|[\r\n])Project reference[^\r\n]*removed.($|[\r\n])");
            cmd.StdOut.Should().NotContain(validref.Name);
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore);
            csproj.NumberOfProjectReferencesWithIncludeContaining(libref.Name).Should().Be(0);
        }
Ejemplo n.º 17
0
        public void WhenPassingMultipleReferencesAndOneOfThemDoesNotExistItRemovesOne()
        {
            var lib      = NewLib();
            var setup    = Setup();
            var libref   = GetLibRef(setup);
            var validref = AddValidRef(setup, lib);

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

            cmd.Should().Pass();
            cmd.StdOut.Should().MatchRegex("(^|[\r\n])Project reference[^\r\n]*removed.($|[\r\n])");
            cmd.StdOut.Should().Contain("could not be found");
            var csproj = lib.CsProj();

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(validref.Name).Should().Be(0);
        }
Ejemplo n.º 18
0
        public void WhenPassingMultipleReferencesAndOneOfThemDoesNotExistItRemovesOne()
        {
            var lib      = NewLibWithFrameworks();
            var setup    = Setup();
            var libref   = GetLibRef(setup);
            var validref = AddValidRef(setup, lib);

            string OutputText = $@"Project reference `{setup.LibCsprojPath}` could not be found.
Project reference `{Path.Combine(TestSetup.ProjectName, setup.ValidRefCsprojRelPath)}` removed.";

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

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

            csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
            csproj.NumberOfProjectReferencesWithIncludeContaining(validref.Name).Should().Be(0);
        }