Beispiel #1
0
        public void WhenRefWithCondAlreadyExistsInNonUniformItemGroupItDoesntDuplicate()
        {
            var setup = Setup();
            var proj  = new ProjDir(Path.Combine(setup.TestRoot, "WithRefCondNonUniform"));

            string contentBefore = proj.CsProjContent();
            var    cmd           = new DotnetCommand(Log, "add", proj.CsProjName, "reference")
                                   .WithWorkingDirectory(proj.Path)
                                   .Execute("-f", FrameworkNet451, setup.LibCsprojRelPath);

            cmd.Should().Pass();
            cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectAlreadyHasAreference, @"..\Lib\Lib.csproj"));
            proj.CsProjContent().Should().BeEquivalentTo(contentBefore);
        }
Beispiel #2
0
        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);
        }
Beispiel #4
0
        public void WhenFrameworkSwitchIsNotMatchingAnyOfTargetedFrameworksItPrintsError(string framework)
        {
            var setup    = Setup(framework);
            var lib      = new ProjDir(setup.LibDir);
            var net45lib = new ProjDir(Path.Combine(setup.TestRoot, "Net45Lib"));

            var csProjContent = lib.CsProjContent();
            var cmd           = new DotnetCommand(Log, "add", lib.CsProjPath, "reference")
                                .Execute($"-f", framework, net45lib.CsProjPath);

            cmd.Should().Fail();
            cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.ProjectDoesNotTargetFramework, setup.LibCsprojPath, framework));

            lib.CsProjContent().Should().BeEquivalentTo(csProjContent);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        public void WhenIncompatibleFrameworkDetectedItPrintsError(bool useFrameworkArg)
        {
            var setup    = Setup(useFrameworkArg.ToString());
            var lib      = new ProjDir(setup.LibDir);
            var net45lib = new ProjDir(Path.Combine(setup.TestRoot, "Net45Lib"));

            List <string> args = new List <string>();

            if (useFrameworkArg)
            {
                args.Add("-f");
                args.Add("net45");
            }
            args.Add(lib.CsProjPath);

            var csProjContent = net45lib.CsProjContent();
            var cmd           = new DotnetCommand(Log, "add", net45lib.CsProjPath, "reference")
                                .Execute(args);

            cmd.Should().Fail();
            cmd.StdErr.Should().MatchRegex(ProjectNotCompatibleErrorMessageRegEx);
            cmd.StdErr.Should().MatchRegex(" - net45");
            net45lib.CsProjContent().Should().BeEquivalentTo(csProjContent);
        }