public void SetUp()
        {
            TemplateLibrary.FileSystem.DeleteDirectory("temp-solution");
            TemplateLibrary.FileSystem.CreateDirectory("temp-solution");

            csProjFile = CsProjFile.CreateAtSolutionDirectory("MyProj", "temp-solution");
        }
Beispiel #2
0
        public void sets_the_assembly_name_and_root_namespace_on_creation()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("Goofy", "Directory");

            project.RootNamespace.ShouldEqual("Goofy");
            project.AssemblyName.ShouldEqual("Goofy");
        }
Beispiel #3
0
        public void AttachReferences(CsProjFile newProject, Dictionary <string, MSBuildItem> referencesUnique)
        {
            var itemGroup2 = newProject.BuildProject.AddNewItemGroup();

            foreach (var refenceItem in referencesUnique)
            {
                var include = refenceItem.Value.Include;

                if (!_includeTestProjects && include.ToLower().Contains("xunit"))
                {
                    continue;
                }

                var refItem = itemGroup2.AddNewItem("Reference", include);
                if (refenceItem.Value.HasMetadata("HintPath"))
                {
                    var hintPath = refenceItem.Value.GetMetadata("HintPath").Replace("..\\..\\..\\..\\", ".\\");
                    hintPath = hintPath.Replace(".\\..\\packages\\", ".\\packages\\");

                    refItem.SetMetadata("HintPath", hintPath);
                }

                if (refenceItem.Value.HasMetadata("Private"))
                {
                    refItem.SetMetadata("Private", refenceItem.Value.GetMetadata("Private"));
                }
            }
        }
Beispiel #4
0
        public void CanWriteEvenWhenFileVersionNotSpecified()
        {
            _fileSystem.Copy("AssemblyInfoWithMissingFileVersionAttribute.cs.fake", @"AssemblyInfoTester\Properties\AssemblyInfo.cs", CopyBehavior.overwrite);
            _project = CsProjFile.LoadFrom(@"AssemblyInfoTester\SlickGridHarness.csproj");

            var assemblyInfo = _project.AssemblyInfo;

            assemblyInfo.AssemblyVersion       = new Version(2, 0, 0, 0);
            assemblyInfo.AssemblyTitle         = "New AssemblyTitle";
            assemblyInfo.AssemblyDescription   = "New AssemblyDescription";
            assemblyInfo.AssemblyConfiguration = "New AssemblyConfiguration";
            assemblyInfo.AssemblyCompany       = "New AssemblyCompany";
            assemblyInfo.AssemblyProduct       = "New AssemblyProduct";
            assemblyInfo.AssemblyCopyright     = "New AssemblyCopyright";

            _project.Save();

            _project     = CsProjFile.LoadFrom(@"AssemblyInfoTester\SlickGridHarness.csproj");
            assemblyInfo = _project.AssemblyInfo;

            Assert.That(assemblyInfo.AssemblyVersion, Is.EqualTo(new Version(2, 0, 0, 0)));
            Assert.That(assemblyInfo.AssemblyFileVersion, Is.Null);
            Assert.That(assemblyInfo.AssemblyTitle, Is.EqualTo("New AssemblyTitle"));
            Assert.That(assemblyInfo.AssemblyDescription, Is.EqualTo("New AssemblyDescription"));
            Assert.That(assemblyInfo.AssemblyConfiguration, Is.EqualTo("New AssemblyConfiguration"));
            Assert.That(assemblyInfo.AssemblyCompany, Is.EqualTo("New AssemblyCompany"));
            Assert.That(assemblyInfo.AssemblyProduct, Is.EqualTo("New AssemblyProduct"));
            Assert.That(assemblyInfo.AssemblyCopyright, Is.EqualTo("New AssemblyCopyright"));
        }
        public void SetUp()
        {
            thePlan = TemplatePlan.CreateClean("copy-references");

            thePlan.FileSystem.WriteStringToFile("ripple.dependencies.config", @"FubuCore
            FubuMVC.Core
            ");

            thePlan.Add(new CreateSolution("References"));
            var originalPlan = new ProjectPlan("References");
            thePlan.Add(originalPlan);
            originalPlan.Add(new SystemReference("System.Data"));
            originalPlan.Add(new SystemReference("System.Configuration"));
            originalPlan.Add(new CopyFileToProject("ripple.dependencies.config", "ripple.dependencies.config"));
            originalPlan.NugetDeclarations.Add("Bottles");
            originalPlan.NugetDeclarations.Add("FubuMVC.Core");
            originalPlan.NugetDeclarations.Add("FubuLocalization");

            testingPlan = new ProjectPlan("References.Testing");
            thePlan.Add(testingPlan);
            thePlan.Add(new CopyProjectReferences("References"));

            thePlan.Execute();

            theOriginalProject = thePlan.Solution.FindProject("References").Project;
            theTestingProject = thePlan.Solution.FindProject("References.Testing").Project;
        }
Beispiel #6
0
        public void can_write_embedded_resources()
        {
            fileSystem.WriteStringToFile("myproj".AppendPath("foo.txt"), "using System.Web;");
            fileSystem.WriteStringToFile("myproj".AppendPath("bar.txt"), "using System.Web;");

            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <EmbeddedResource>("foo.txt");
            project.Add <EmbeddedResource>("bar.txt");

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.All <EmbeddedResource>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("bar.txt", "foo.txt");

            project2.Add <EmbeddedResource>("ten.txt");
            project2.Add <EmbeddedResource>("aaa.txt");

            project2.Save();

            var project3 = CsProjFile.LoadFrom(project2.FileName);

            project3.All <EmbeddedResource>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("aaa.txt", "bar.txt", "foo.txt", "ten.txt");
        }
        public void CanUpdateCsProjFile()
        {
            //arrange
            var filename = Path.Combine("FileTypes", "project.csproj");
            var file     = new CsProjFile(filename);
            var results  = new List <Result>
            {
                new Result("test1", new VersionInfo(new NuGetVersion(0, 1, 0, 1), DateTime.Today), new VersionInfo(new NuGetVersion(1, 2, 3), DateTime.Today)),
                new Result("test2", new VersionInfo(new NuGetVersion(0, 2, 0), DateTime.Today), new VersionInfo(new NuGetVersion(2, 3, 4), DateTime.Today)),
                new Result("test3", new VersionInfo(new NuGetVersion(0, 3, 0), DateTime.Today), new VersionInfo(new NuGetVersion(3, 4, 5), DateTime.Today)),
                new Result("test4", new VersionInfo(new NuGetVersion(0, 4, 0), DateTime.Today), new VersionInfo(new NuGetVersion(4, 5, 6), DateTime.Today)),
                new Result("test5", new VersionInfo(new NuGetVersion(0, 5, 0), DateTime.Today), new VersionInfo(new NuGetVersion(5, 6, 7), DateTime.Today)),
            };

            //act
            file.Update(results);

            //assert
            var newFile = new CsProjFile(filename);

            Assert.Equal("1.2.3", newFile.Packages["test1"].ToString());
            Assert.Equal("2.3.4", newFile.Packages["test2"].ToString());
            Assert.Equal("3.4.5", newFile.Packages["test3"].ToString());
            Assert.Equal("4.5.6", newFile.Packages["test4"].ToString());
            Assert.Equal("5.6.7", newFile.Packages["test5"].ToString());
            Assert.Null(newFile.Packages["test6"]);
        }
Beispiel #8
0
        public void can_write_and_read_project_references()
        {
            var include = @"..\OtherProject\OtherProject.csproj";


            var project    = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");
            var reference1 = new ProjectReference(include)
            {
                ProjectName = "OtherProject",
                ProjectGuid = Guid.NewGuid()
            };

            project.Add(reference1);

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            var reference2 = project2.Find <ProjectReference>(reference1.Include);

            var all = project2.All <ProjectReference>();

            reference2.ShouldNotBeNull();
            reference2.ProjectName.ShouldEqual(reference1.ProjectName);
            reference2.ProjectGuid.ShouldEqual(reference1.ProjectGuid);
        }
Beispiel #9
0
        private void createZipFile(AssemblyPackageInput input, string childFolderName, ZipFileService zipService, FileSet fileSearch)
        {
            var zipRequest = BuildZipRequest(input, fileSearch);

            if (zipRequest == null)
            {
                ConsoleWriter.Write("No content for " + childFolderName);

                return;
            }

            // Hackey, but it makes /data and data/*.* work
            if (fileSystem.DirectoryExists(input.RootFolder.AppendPath(childFolderName)) && zipRequest.FileSet.Include.StartsWith(childFolderName, StringComparison.InvariantCultureIgnoreCase))
            {
                zipRequest.FileSet       = FileSet.Deep("*.*");
                zipRequest.RootDirectory = zipRequest.RootDirectory.AppendPath(childFolderName);
            }

            var zipFileName = "pak-{0}.zip".ToFormat(childFolderName);

            // do not create a zip file if there's no files there.
            if (!fileSystem.FindFiles(input.RootFolder, zipRequest.FileSet).Any())
            {
                Console.WriteLine("No matching files for Bottle directory " + childFolderName);

                var projectFileName = input.FindCsProjFile();
                var csProjFile      = CsProjFile.LoadFrom(projectFileName);
                if (csProjFile.Find <EmbeddedResource>(zipFileName) != null)
                {
                    csProjFile.Remove <EmbeddedResource>(zipFileName);
                    csProjFile.Save();
                }

                var zipFilePath = input.RootFolder.AppendPath(zipFileName);
                if (fileSystem.FileExists(zipFilePath))
                {
                    Console.WriteLine("Removing obsolete file " + zipFilePath);
                    fileSystem.DeleteFile(zipFilePath);
                }


                return;
            }


            var contentFile = FileSystem.Combine(input.RootFolder, zipFileName);

            ConsoleWriter.Write("Creating zip file " + contentFile);
            fileSystem.DeleteFile(contentFile);


            zipService.CreateZipFile(contentFile, file => file.AddFiles(zipRequest));

            if (input.ProjFileFlag.IsEmpty())
            {
                return;
            }

            attachZipFileToProjectFile(input, zipFileName);
        }
Beispiel #10
0
        public void add_code_files()
        {
            fileSystem.WriteStringToFile("myproj".AppendPath("foo.cs"), "using System.Web;");
            fileSystem.WriteStringToFile("myproj".AppendPath("bar.cs"), "using System.Web;");

            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <CodeFile>("foo.cs");
            project.Add <CodeFile>("bar.cs");

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("bar.cs", "foo.cs");

            project2.Add <CodeFile>("ten.cs");
            project2.Add <CodeFile>("aaa.cs");

            project2.Save();

            var project3 = CsProjFile.LoadFrom(project2.FileName);

            project3.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("aaa.cs", "bar.cs", "foo.cs", "ten.cs");
        }
        public void SetUp()
        {
            TemplateLibrary.FileSystem.DeleteDirectory("temp-solution");
            TemplateLibrary.FileSystem.CreateDirectory("temp-solution");

            csProjFile = CsProjFile.CreateAtSolutionDirectory("MyProj", "temp-solution");
        }
        public void CanWriteAllAtrributes()
        {
            var assemblyInfo = _project.AssemblyInfo;
            assemblyInfo.AssemblyVersion = new Version(2, 0, 0, 0);
            assemblyInfo.AssemblyFileVersion = new Version(2, 0, 0, 120);
            assemblyInfo.AssemblyTitle = "New AssemblyTitle";
            assemblyInfo.AssemblyDescription = "New AssemblyDescription";
            assemblyInfo.AssemblyConfiguration = "New AssemblyConfiguration";
            assemblyInfo.AssemblyCompany = "New AssemblyCompany";
            assemblyInfo.AssemblyProduct = "New AssemblyProduct";
            assemblyInfo.AssemblyCopyright = "New AssemblyCopyright";

            _project.Save();

            _project = CsProjFile.LoadFrom(@"AssemblyInfoTester\SlickGridHarness.csproj");
            assemblyInfo = _project.AssemblyInfo;

            Assert.That(assemblyInfo.AssemblyVersion, Is.EqualTo(new Version(2, 0, 0, 0)));
            Assert.That(assemblyInfo.AssemblyFileVersion, Is.EqualTo(new Version(2, 0, 0, 120)));
            Assert.That(assemblyInfo.AssemblyTitle, Is.EqualTo("New AssemblyTitle"));
            Assert.That(assemblyInfo.AssemblyDescription, Is.EqualTo("New AssemblyDescription"));
            Assert.That(assemblyInfo.AssemblyConfiguration, Is.EqualTo("New AssemblyConfiguration"));
            Assert.That(assemblyInfo.AssemblyCompany, Is.EqualTo("New AssemblyCompany"));
            Assert.That(assemblyInfo.AssemblyProduct, Is.EqualTo("New AssemblyProduct"));
            Assert.That(assemblyInfo.AssemblyCopyright, Is.EqualTo("New AssemblyCopyright"));
        }
        public void SetUp()
        {
            thePlan = TemplatePlan.CreateClean("copy-references");

            thePlan.FileSystem.WriteStringToFile("ripple.dependencies.config", @"FubuCore
FubuMVC.Core
");

            thePlan.Add(new CreateSolution("References"));
            var originalPlan = new ProjectPlan("References");

            thePlan.Add(originalPlan);
            originalPlan.Add(new SystemReference("System.Data"));
            originalPlan.Add(new SystemReference("System.Configuration"));
            originalPlan.Add(new CopyFileToProject("ripple.dependencies.config", "ripple.dependencies.config"));
            originalPlan.NugetDeclarations.Add("Bottles");
            originalPlan.NugetDeclarations.Add("FubuMVC.Core");
            originalPlan.NugetDeclarations.Add("FubuLocalization");

            testingPlan = new ProjectPlan("References.Testing");
            thePlan.Add(testingPlan);
            thePlan.Add(new CopyProjectReferences("References"));


            thePlan.Execute();

            theOriginalProject = thePlan.Solution.FindProject("References").Project;
            theTestingProject  = thePlan.Solution.FindProject("References.Testing").Project;
        }
        public void adding_an_assembly_reference()
        {
            // SAMPLE: assembly-reference
            var project = CsProjFile.CreateAtLocation("MyProject.csproj", "MyProject");

            project.Add(new AssemblyReference("MyOtherLibrary")
            {
                HintPath        = "../packages/MyOtherLibrary/lib/MyOtherLibrary.dll",
                SpecificVersion = false
            });

            // Find an existing reference by assembly name
            var reference = project.Find <AssemblyReference>("MyOtherLibrary");

            // Remove a reference by assembly name
            project.Remove <AssemblyReference>("ObsoleteLibrary");

            // or remove by the object
            project.Remove(reference);

            // Access all the references to the project.
            // This structure closely mimics the MsBuild schema, so the assembly name
            // is "Include"
            project.All <AssemblyReference>().Each(x => Debug.WriteLine(x.Include));
            // ENDSAMPLE


            reference.HintPath.ShouldEqual("../packages/MyOtherLibrary/lib/MyOtherLibrary.dll");
        }
        public void DoesntRaiseEventOnUnloadedFileModified()
        {
            int invocationsCount = 0;
            Action <FileLoadEventArgs> callback = (FileLoadEventArgs args) =>
            {
                if (args.UnloadedFiles?.Any() ?? false)
                {
                    invocationsCount++;
                }
            };
            var @event     = TestUtils.GetMockEvent <FileLoadEvent, FileLoadEventArgs>(callback);
            var aggregator = TestUtils.GetMockAggregator();

            aggregator.Setup(a => a.GetEvent <FileLoadEvent>()).Returns(@event.Object);
            SourceProjectsViewModel vm = new SourceProjectsViewModel(aggregator.Object);
            var projFile = new CsProjFile(new XmlDocument())
            {
                IsSelected = false
            };

            vm.ProjectFiles.Add(projFile);
            vm.ProjectFiles.RemoveAt(0); // here invocationsCount has to be 1
            projFile.IsSelected = true;  // no change in invocationsCount should occur here
            Assert.AreEqual(1, invocationsCount);
        }
Beispiel #16
0
        public static void GenerateProject(YamlSpecification specification)
        {
            var project           = CsProjFile.LoadFrom(_testProjectFolder + @"Nest.Tests.Integration.Yaml.csproj");
            var existingYamlTests = project.All <CodeFile>().Where(c => c.Link != null && c.Link.EndsWith(".yaml.cs"));

            foreach (var c in existingYamlTests)
            {
                project.Remove(c);
            }

            var definitions = specification.Definitions;

            using (var pbar = new ProgressBar(definitions.Count, "Generating Code and project for yaml tests", ConsoleColor.Blue))
                foreach (var kv in specification.Definitions)
                {
                    var folder = kv.Key;
                    foreach (var d in kv.Value)
                    {
                        var path = folder + @"\" + d.FileName + ".cs";
                        if (!Directory.Exists(_testProjectFolder + folder))
                        {
                            Directory.CreateDirectory(_testProjectFolder + folder);
                        }

                        GenerateTestFileFromView(_testProjectFolder + path, d);
                        project.Add <CodeFile>(path);
                    }
                    pbar.Tick();
                }
            project.Save();
        }
        public void build_project_with_assembly_info_fubu_test(SolutionBuilderContext context, ISolutionContext solutionContext, FubuCsProjFile.CsProjFile project)
        {
            "Given I have a solution builder context"
            ._(() => context = ServiceLocator.Resolve <SolutionBuilderContext>());

            "When I call build with a solution, a project and an assembly info"
            ._(() => solutionContext = context.CreateBuilder()
                                       .WithSolution(item => item.Path = Path.Combine(context.RootDirectory, "Sally.sln"))
                                       .WithProject(item => item.Name  = "FrodoFx")
                                       .WithFile <AssemblyInfo>(item =>
            {
                item.Title                = "FrodoFx";
                item.Description          = "Middle earth web server";
                item.FileVersion          = new Version(0, 0, 1, 2049);
                item.Version              = new Version(0, 0, 1);
                item.InformationalVersion = "release";
            })
                                       .Build());

            "It should return the build project with an assembly info"
            ._(() =>
            {
                project = new CsProjFile(solutionContext.Solution.Projects.FirstOrDefault().Path);
                project.Should().NotBeNull("the project should not be null");

                project.AssemblyInfo.Should().NotBeNull("the assembly info should not be null");
            });

            "And the assembly info title should be set"
            ._(() => project.AssemblyInfo.AssemblyTitle.Should().Be("FrodoFx"))
            .Teardown(() => context.TearDown());
        }
Beispiel #18
0
 public void WithEmptyStringAsFileName_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var csproj = new CsProjFile <CsAbstractMetadataMock>(string.Empty);
     });
 }
Beispiel #19
0
        public void SetUp()
        {
            var context = TemplatePlan.CreateClean("assembly-info");

            context.Add(new CreateSolution("AssemblyInfoSolution"));

            var project = new ProjectPlan("MyProject");

            context.Add(project);

            var system = new FileSystem();

            system.CreateDirectory("assembly-info");
            system.CreateDirectory("assembly-info", "src");
            system.CreateDirectory("assembly-info", "src", "MyProject");
            system.CreateDirectory("assembly-info", "src", "MyProject", "Properties");


            var expectedPath = "assembly-info".AppendPath("src", "MyProject", "Properties", "AssemblyInfo.cs");

            system.WriteStringToFile(expectedPath, @"using System.Reflection;

[assembly: AssemblyTitle('MyProject')]
".Replace("'", "\""));

            var alteration = new AssemblyInfoAlteration("using System.Reflection;", "[assembly: AssemblyTitle(\"%ASSEMBLYNAME%\")]", "using FubuMVC.Core;", "[assembly: FubuModule]");

            project.Add(alteration);

            context.Execute();

            theProject  = CsProjFile.LoadFrom("assembly-info".AppendPath("src", "MyProject", "MyProject.csproj"));
            theContents =
                new FileSystem().ReadStringFromFile(expectedPath);
        }
Beispiel #20
0
        public void read_project_type_as_a_class_library_if_no_explicit_project_type()
        {
            var project = CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj");

            project.ProjectTypes().Single()
            .ShouldEqual(Guid.Parse("FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"));
        }
Beispiel #21
0
        public void CanWriteAllAtrributes()
        {
            var assemblyInfo = _project.AssemblyInfo;

            assemblyInfo.AssemblyVersion       = new Version(2, 0, 0, 0);
            assemblyInfo.AssemblyFileVersion   = new Version(2, 0, 0, 120);
            assemblyInfo.AssemblyTitle         = "New AssemblyTitle";
            assemblyInfo.AssemblyDescription   = "New AssemblyDescription";
            assemblyInfo.AssemblyConfiguration = "New AssemblyConfiguration";
            assemblyInfo.AssemblyCompany       = "New AssemblyCompany";
            assemblyInfo.AssemblyProduct       = "New AssemblyProduct";
            assemblyInfo.AssemblyCopyright     = "New AssemblyCopyright";

            _project.Save();

            _project     = CsProjFile.LoadFrom(@"AssemblyInfoTester\SlickGridHarness.csproj");
            assemblyInfo = _project.AssemblyInfo;

            Assert.That(assemblyInfo.AssemblyVersion, Is.EqualTo(new Version(2, 0, 0, 0)));
            Assert.That(assemblyInfo.AssemblyFileVersion, Is.EqualTo(new Version(2, 0, 0, 120)));
            Assert.That(assemblyInfo.AssemblyTitle, Is.EqualTo("New AssemblyTitle"));
            Assert.That(assemblyInfo.AssemblyDescription, Is.EqualTo("New AssemblyDescription"));
            Assert.That(assemblyInfo.AssemblyConfiguration, Is.EqualTo("New AssemblyConfiguration"));
            Assert.That(assemblyInfo.AssemblyCompany, Is.EqualTo("New AssemblyCompany"));
            Assert.That(assemblyInfo.AssemblyProduct, Is.EqualTo("New AssemblyProduct"));
            Assert.That(assemblyInfo.AssemblyCopyright, Is.EqualTo("New AssemblyCopyright"));
        }
Beispiel #22
0
        public void can_read_then_save_maintains_orginal_node_order()
        {
            // Can be important to maintain orginal node order to minimize merge conflicts checking in
            // changes to a proj file
            var origProj = CsProjFile.LoadFrom("SlickGridHarness.csproj");

            origProj.BuildProject.Settings = MSBuildProjectSettings.MinimizeChanges;
            origProj.Save("MyProj.csproj");

            origProj = CsProjFile.LoadFrom("SlickGridHarness.csproj");
            var newProj = CsProjFile.LoadFrom("MyProj.csproj");

            for (int i = 0; i < origProj.BuildProject.ItemGroups.Count(); i++)
            {
                var origGroup = origProj.BuildProject.ItemGroups.ElementAt(i);
                var newGroup  = newProj.BuildProject.ItemGroups.ElementAt(i);

                for (int j = 0; j < origGroup.Items.Count(); j++)
                {
                    var origItem = origGroup.Items.ElementAt(j);
                    var newItem  = newGroup.Items.ElementAt(j);

                    origItem.Include.ShouldEqual(newItem.Include);
                }
            }
        }
Beispiel #23
0
        public void remove_code_file_2()
        {
            var project = CsProjFile.CreateAtSolutionDirectory("MyProj", "myproj");

            project.Add <CodeFile>("foo.cs");
            project.Add <CodeFile>("bar.cs");

            project.Save();

            var project2 = CsProjFile.LoadFrom(project.FileName);

            project2.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("bar.cs", "foo.cs");

            project2.Remove <CodeFile>(project2.Find <CodeFile>("bar.cs"));
            project2.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("foo.cs");

            project2.Save();

            var project3 = CsProjFile.LoadFrom(project.FileName);

            project3.All <CodeFile>().Select(x => x.Include)
            .ShouldHaveTheSameElementsAs("foo.cs");
        }
Beispiel #24
0
 public void Alter(CsProjFile file, ProjectPlan plan)
 {
     TemplateLibrary.FileSystem.CreateDirectory(FubuCore.StringExtensions.AppendPath(file.ProjectDirectory, new string[]
     {
         this._relativePath
     }));
 }
Beispiel #25
0
        public void SetUp()
        {
            theFilename = "Bottles.txt";
            var stream = GetType()
                         .Assembly
                         .GetManifestResourceStream(GetType(), "ProjectTemplate.txt");

            new FileSystem().WriteStreamToFile(theFilename, stream);

            theCsProj = new CsProjFile(theFilename, null);

            theCsProj
            .References
            .ShouldHaveTheSameElementKeysAs(new[]
            {
                "FubuCore",
                "Ionic.Zip",
                "Ionic.Zip, Version=1.9.1.8, Culture=neutral, processorArchitecture=MSIL",
                "System",
                "System.Core",
                "System.Web",
                "System.Xml"
            }, x => x.Name);

            theCsProj.RemoveDuplicateReferences();
            theCsProj.Write();

            theCsProj = null;
            theCsProj = new CsProjFile(theFilename, null);
        }
Beispiel #26
0
        public void can_read_reference_with_hint_path()
        {
            var project = CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj");

            var reference = project.Find <AssemblyReference>("Rhino.Mocks");

            reference.HintPath.ShouldEqual(@"..\packages\RhinoMocks\lib\net\Rhino.Mocks.dll");
        }
Beispiel #27
0
 private static void copyNugetDeclarations(ProjectPlan originalPlan, ProjectPlan testPlan, CsProjFile original,
                                           CsProjFile testProject)
 {
     originalPlan.NugetDeclarations.Each(x => testPlan.NugetDeclarations.Fill(x));
     original.All <AssemblyReference>()
     .Where(x => x.HintPath.IsEmpty())
     .Each(x => testProject.Add <AssemblyReference>(x.Include));
 }
Beispiel #28
0
        public void SetUp()
        {
            new FileSystem().DeleteDirectory("Templated");
            new FileSystem().CreateDirectory("Templated");

            theProject = CsProjFile.CreateAtSolutionDirectory("TemplatedProject", "Templated");
            thePlan    = new ProjectPlan(theProject.ProjectName);
        }
Beispiel #29
0
 public void IfPropertyWasNotFound_ReturnsNull()
 {
     using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(Data)))
         using (var csproj = new CsProjFile <CsMetadataMock>(stream))
         {
             Assert.IsNull(csproj.Metadata.NonExistentProp);
         }
 }
Beispiel #30
0
        public void can_write_target_framework()
        {
            var project = CsProjFile.LoadFrom("SlickGridHarness.csproj");

            project.TargetFrameworkVersion = "v4.5";
            project.Save();

            project = CsProjFile.LoadFrom("SlickGridHarness.csproj");
            project.TargetFrameworkVersion.ToString().ShouldEqual("v4.5");
        }
Beispiel #31
0
        public void can_write_platform()
        {
            var project = CsProjFile.LoadFrom("SlickGridHarness.csproj");

            project.Platform = "x86";
            project.Save();

            project = CsProjFile.LoadFrom("SlickGridHarness.csproj");
            project.Platform.ShouldEqual("x86");
        }
Beispiel #32
0
        public void add_an_existing_project_to_a_new_solution()
        {
            var solution = Solution.CreateNew(@"solutions\sillydir", "newsolution");

            File.Copy("FubuMVC.SlickGrid.Docs.csproj.fake", "FubuMVC.SlickGrid.Docs.csproj", true);

            solution.AddProject(CsProjFile.LoadFrom("FubuMVC.SlickGrid.Docs.csproj"));

            solution.FindProject("FubuMVC.SlickGrid.Docs").ShouldNotBeNull();
        }
        public void creating_a_project_references_from_a_project_copies_attributes()
        {
            var sourceProject = new CsProjFile(@"Solution1\harness\SlickGridHarness.csproj");
            var targetProject = new CsProjFile(@"Solution1\docs\FubuMVC.SlickGrid.Docs.csproj");
            var projectReference = new ProjectReference(targetProject, sourceProject);

            projectReference.Include.ShouldEqual(@"..\harness\SlickGridHarness.csproj");
            projectReference.ProjectGuid.ShouldEqual(sourceProject.ProjectGuid);
            projectReference.ProjectName.ShouldEqual(sourceProject.ProjectName);
        }
Beispiel #34
0
        public void creating_a_project_references_from_a_project_copies_attributes()
        {
            var sourceProject    = new CsProjFile(@"Solution1\harness\SlickGridHarness.csproj");
            var targetProject    = new CsProjFile(@"Solution1\docs\FubuMVC.SlickGrid.Docs.csproj");
            var projectReference = new ProjectReference(targetProject, sourceProject);

            projectReference.Include.ShouldEqual(@"..\harness\SlickGridHarness.csproj");
            projectReference.ProjectGuid.ShouldEqual(sourceProject.ProjectGuid);
            projectReference.ProjectName.ShouldEqual(sourceProject.ProjectName);
        }
        public void Alter(CsProjFile file, ProjectPlan plan)
        {
            var fileSystem = new FileSystem();
            var rawText = fileSystem.ReadStringFromFile(_source);

            var templatedText = plan.
                ApplySubstitutions(rawText, _relativePath);

            var expectedPath = file.ProjectDirectory.AppendPath(_relativePath);

            fileSystem.WriteStringToFile(expectedPath, templatedText);
        }
        public void Alter(CsProjFile file, ProjectPlan plan)
        {
            var codeFile = file.Find<CodeFile>(AssemblyInfoPath) ?? file.Add<CodeFile>(AssemblyInfoPath);

            var path = file.PathTo(codeFile);
            var parentDirectory = path.ParentDirectory();
            if (!Directory.Exists(parentDirectory))
            {
                Directory.CreateDirectory(parentDirectory);
            }

            new FileSystem().AlterFlatFile(path, contents => Alter(contents, plan));
        }
        public void Alter(CsProjFile file, ProjectPlan plan)
        {
            var includePath = plan.ApplySubstitutions(_relativePath);
            var filename = file.FileName.ParentDirectory().AppendPath(includePath);
            if (!filename.EndsWith(".cs"))
            {
                filename = filename + ".cs";
            }

            var text = plan.ApplySubstitutions(_rawText, _relativePath);

            new FileSystem().WriteStringToFile(filename, text);

            file.Add<CodeFile>(includePath);
        }
        public void CanReadAttributes_when_some_attributes_are_missing()
        {
            _fileSystem.Copy("AssemblyInfoWithMissingFileVersionAttribute.cs.fake", @"AssemblyInfoTester\Properties\AssemblyInfo.cs", CopyBehavior.overwrite);
            _project = CsProjFile.LoadFrom(@"AssemblyInfoTester\SlickGridHarness.csproj");
            var assemblyInfo = _project.AssemblyInfo;

            Assert.That(assemblyInfo.AssemblyVersion, Is.EqualTo(new Version(1, 0, 0, 0)));
            Assert.That(assemblyInfo.AssemblyTitle, Is.EqualTo("FubuCsProjFile.Testing"));
            Assert.That(assemblyInfo.AssemblyDescription, Is.EqualTo("FubuCsProjFile.Testing Is Amazing"));
            Assert.That(assemblyInfo.AssemblyConfiguration, Is.EqualTo("Debug build on machine build02"));
            Assert.That(assemblyInfo.AssemblyCompany, Is.EqualTo("Fubu"));
            Assert.That(assemblyInfo.AssemblyProduct, Is.EqualTo("FubuCsProjFile.Testing Product"));
            Assert.That(assemblyInfo.AssemblyCopyright, Is.EqualTo("Copyright ©  2014"));
            Assert.That(assemblyInfo.AssemblyInformationalVersion, Is.Null);
        }
        public void SetUp()
        {
            var context = TemplatePlan.CreateClean("assembly-info");
            context.Add(new CreateSolution("AssemblyInfoSolution"));

            var project = new ProjectPlan("MyProject");

            context.Add(project);

            var alteration = new AssemblyInfoAlteration("using System.Reflection;", "[assembly: AssemblyTitle(\"%ASSEMBLY_NAME%\")]", "using FubuMVC.Core;", "[assembly: FubuModule]");
            project.Add(alteration);

            context.Execute();

            theProject = CsProjFile.LoadFrom("assembly-info".AppendPath("src", "MyProject", "MyProject.csproj"));
            theContents =
                new FileSystem().ReadStringFromFile("assembly-info".AppendPath("src", "MyProject", "Properties",
                                                                               "AssemblyInfo.cs"));
        }
        public void CanWriteEvenWhenFileVersionNotSpecified()
        {
            _fileSystem.Copy("AssemblyInfoWithMissingFileVersionAttribute.cs.fake", @"AssemblyInfoTester\Properties\AssemblyInfo.cs", CopyBehavior.overwrite);
            _project = CsProjFile.LoadFrom(@"AssemblyInfoTester\SlickGridHarness.csproj");

            var assemblyInfo = _project.AssemblyInfo;
            assemblyInfo.AssemblyVersion = new Version(2, 0, 0, 0);
            assemblyInfo.AssemblyTitle = "New AssemblyTitle";
            assemblyInfo.AssemblyDescription = "New AssemblyDescription";
            assemblyInfo.AssemblyConfiguration = "New AssemblyConfiguration";
            assemblyInfo.AssemblyCompany = "New AssemblyCompany";
            assemblyInfo.AssemblyProduct = "New AssemblyProduct";
            assemblyInfo.AssemblyCopyright = "New AssemblyCopyright";

            _project.Save();

            _project = CsProjFile.LoadFrom(@"AssemblyInfoTester\SlickGridHarness.csproj");
            assemblyInfo = _project.AssemblyInfo;

            Assert.That(assemblyInfo.AssemblyVersion, Is.EqualTo(new Version(2, 0, 0, 0)));
            Assert.That(assemblyInfo.AssemblyFileVersion, Is.Null);
            Assert.That(assemblyInfo.AssemblyTitle, Is.EqualTo("New AssemblyTitle"));
            Assert.That(assemblyInfo.AssemblyDescription, Is.EqualTo("New AssemblyDescription"));
            Assert.That(assemblyInfo.AssemblyConfiguration, Is.EqualTo("New AssemblyConfiguration"));
            Assert.That(assemblyInfo.AssemblyCompany, Is.EqualTo("New AssemblyCompany"));
            Assert.That(assemblyInfo.AssemblyProduct, Is.EqualTo("New AssemblyProduct"));
            Assert.That(assemblyInfo.AssemblyCopyright, Is.EqualTo("New AssemblyCopyright"));
        }
 public void Alter(CsProjFile file, ProjectPlan plan)
 {
     TemplateLibrary.FileSystem.CreateDirectory(file.ProjectDirectory.AppendPath(_relativePath));
 }
 public void Alter(CsProjFile file, ProjectPlan plan)
 {
     file.Add<AssemblyReference>(_assemblyName);
 }
 public void BeforeEveryTest()
 {
     _fileSystem.Copy("SlickGridHarness.csproj.fake", @"AssemblyInfoTester\SlickGridHarness.csproj", CopyBehavior.overwrite);
     _fileSystem.Copy("AssemblyInfo.cs.fake", @"AssemblyInfoTester\Properties\AssemblyInfo.cs", CopyBehavior.overwrite);
     _project = CsProjFile.LoadFrom(@"AssemblyInfoTester\SlickGridHarness.csproj");
 }
        public void SetUp()
        {
            new FileSystem().DeleteDirectory("Templated");
            new FileSystem().CreateDirectory("Templated");

            theProject = CsProjFile.CreateAtSolutionDirectory("TemplatedProject", "Templated");
            thePlan = new ProjectPlan(theProject.ProjectName);
        }