public void WhenPassingMultipleReferencesAndOneOfThemDoesNotExistItRemovesOne() { var setup = Setup(); var lib = NewLibWithFrameworks(setup.TestRoot); var libref = GetLibRef(setup); var validref = AddValidRef(setup, lib); string outputText = $@"{string.Format(CommonLocalizableStrings.ProjectReferenceCouldNotBeFound, setup.LibCsprojPath)} {string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, Path.Combine(setup.ValidRefCsprojRelPath))}"; int noCondBefore = lib.CsProj().NumberOfItemGroupsWithoutCondition(); var cmd = new RemoveReferenceCommand(Log) .WithProject(lib.CsProjPath) .WithWorkingDirectory(setup.TestRoot) .Execute(libref.CsProjPath, validref.CsProjPath); cmd.Should().Pass(); cmd.StdOut.Should().BeVisuallyEquivalentTo(outputText); var csproj = lib.CsProj(); csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1); csproj.NumberOfProjectReferencesWithIncludeContaining(validref.Name).Should().Be(0); }
public void WhenDuplicateReferencesArePresentItRemovesThemAll() { var setup = Setup(); var proj = new ProjDir(Path.Combine(setup.TestRoot, "WithDoubledRef")); var libref = GetLibRef(setup); string removedText = $@"{string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, setup.LibCsprojRelPath)} {string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, setup.LibCsprojRelPath)}"; int noCondBefore = proj.CsProj().NumberOfItemGroupsWithoutCondition(); var cmd = new RemoveReferenceCommand(Log) .WithProject(proj.CsProjPath) .WithWorkingDirectory(setup.TestRoot) .Execute(libref.CsProjPath); cmd.Should().Pass(); cmd.StdOut.Should().BeVisuallyEquivalentTo(removedText); var csproj = proj.CsProj(); csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1); csproj.NumberOfProjectReferencesWithIncludeContaining(libref.Name).Should().Be(0); }
public void WhenPassingMultipleReferencesAndOneOfThemDoesNotExistItRemovesOne() { var setup = Setup(); var lib = NewLibWithFrameworks(setup.TestRoot); var libref = GetLibRef(setup); var validref = AddValidRef(setup, lib); string OutputText = $@"Project reference `{setup.LibCsprojPath}` could not be found. Project reference `{Path.Combine(setup.ValidRefCsprojRelPath)}` removed."; int noCondBefore = lib.CsProj().NumberOfItemGroupsWithoutCondition(); var cmd = new RemoveReferenceCommand() .WithWorkingDirectory(setup.TestRoot) .WithProject(lib.CsProjPath) .Execute($"\"{libref.CsProjPath}\" \"{validref.CsProjPath}\""); cmd.Should().Pass(); cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText); var csproj = lib.CsProj(); csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1); csproj.NumberOfProjectReferencesWithIncludeContaining(validref.Name).Should().Be(0); }
public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg) { var cmd = new RemoveReferenceCommand().Execute(helpArg); cmd.Should().Pass(); cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); }