示例#1
0
        public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
        {
            var cmd = new RemoveP2PCommand().Execute(helpArg);

            cmd.Should().Pass();
            cmd.StdOut.Should().Contain("Usage");
        }
示例#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);
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
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);
        }
示例#10
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);
        }
示例#11
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);
        }
示例#12
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);
        }