Inheritance: Rosalia.FileSystem.DefaultFile, IFileSystemStub
コード例 #1
0
        public void Execute_WithDependencies_ShouldRenderMetadata()
        {
            var destination = new FileStub("output");

            new GenerateNuGetSpecTask(destination)
                .WithDependency("id1", "v1.0")
                .WithDependency("id2")
                .WithDependency("id3", "v1.0", "net40")
                .Execute()
                .AssertSuccess();

            Assert.That(destination.Content.Trim().NormalizeLineEnding(), Is.EqualTo(
            @"<?xml version='1.0' encoding='utf-8'?>
            <package xmlns='http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'>
              <metadata>
            <dependencies>
              <group>
            <dependency id='id1' version='v1.0' />
            <dependency id='id2' />
              </group>
              <group targetFramework='net40'>
            <dependency id='id3' version='v1.0' />
              </group>
            </dependencies>
              </metadata>
            </package>".NormalizeLineEnding()));
        }
コード例 #2
0
        public void Execute_ValidInput_ShouldGenerateOutput()
        {
            var destination = new FileStub("AssemblyInfo.cs");
            var task = new GenerateAssemblyInfo(destination)
            {
                Attributes =
                {
                    _ => new AssemblyVersionAttribute("1.0.42"),
                    _ => new AssemblyCompanyAttribute("Starfuckers, Inc.")
                }
            };

            task
                .Execute()
                .AssertSuccess();

            Assert.That(destination.Content.Trim(), Is.EqualTo(
            @"//------------------------------------------------------------------------------
            // <auto-generated>
            //     This code was generated by a tool.
            //
            //     Changes to this file may cause incorrect behavior and will be lost if
            //     the code is regenerated.
            // </auto-generated>
            //------------------------------------------------------------------------------

            using System.Reflection;

            [assembly: AssemblyVersionAttribute(""1.0.42"")]
            [assembly: AssemblyCompanyAttribute(""Starfuckers, Inc."")]"));
        }
コード例 #3
0
        public void Execute_WithDependenciesFromPackagesConfig_ShouldRenderDependencies()
        {
            FileStub destination = new FileStub("output");

            new GenerateNuGetSpecTask(destination)
                .WithDependenciesFromPackagesConfig(new FileStub("packages.config")
                {
                    Content = @"<?xml version='1.0' encoding='utf-8'?>
            <packages>
              <package id='Common.Logging' version='3.0.0' targetFramework='net35' />
              <package id='Common.Logging.Core' version='3.0.0' targetFramework='net35' />
              <package id='Quartz' version='2.3.3' targetFramework='net35' />
            </packages>"
                })
                .Execute();

            Assert.That(destination.Content.Trim().NormalizeLineEnding(), Is.EqualTo(
            @"<?xml version='1.0' encoding='utf-8'?>
            <package xmlns='http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'>
              <metadata>
            <dependencies>
              <group targetFramework='net35'>
            <dependency id='Common.Logging' version='3.0.0' />
            <dependency id='Common.Logging.Core' version='3.0.0' />
            <dependency id='Quartz' version='2.3.3' />
              </group>
            </dependencies>
              </metadata>
            </package>".NormalizeLineEnding()));
        }
コード例 #4
0
        public void Execute_BooleanAsAtributeArgument_ShouldGenerateOutput()
        {
            var destination = new FileStub("AssemblyInfo.cs");
            var task = new GenerateAssemblyInfo(destination)
            {
                Attributes =
                {
                    _ => new ComVisibleAttribute(false)
                }
            };

            task
                .Execute()
                .AssertSuccess();

            Assert.That(destination.Content.Trim(), Is.EqualTo(
            @"//------------------------------------------------------------------------------
            // <auto-generated>
            //     This code was generated by a tool.
            //
            //     Changes to this file may cause incorrect behavior and will be lost if
            //     the code is regenerated.
            // </auto-generated>
            //------------------------------------------------------------------------------

            using System.Runtime.InteropServices;

            [assembly: ComVisibleAttribute(false)]"));
        }
コード例 #5
0
        public void Execute_WithReferences_ShouldRenderReferences()
        {
            var destination = new FileStub("output");

            new GenerateNuGetSpecTask(destination)
                .WithReference("My.Reference1.dll")
                .WithReference("My.Reference2.dll")
                .Execute();

            Assert.That(destination.Content.Trim().NormalizeLineEnding(), Is.EqualTo(
            @"<?xml version='1.0' encoding='utf-8'?>
            <package xmlns='http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'>
              <metadata>
            <references>
              <reference file='My.Reference1.dll' />
              <reference file='My.Reference2.dll' />
            </references>
              </metadata>
            </package>".NormalizeLineEnding()));
        }
コード例 #6
0
        public void Execute_WithMetadata_ShouldRenderMetadata()
        {
            var destination = new FileStub("output");

            new GenerateNuGetSpecTask(destination)
                .Id("testId")
                .Execute()
                .AssertSuccess();

            Assert.That(destination.Content.NormalizeLineEnding(), Does.Contain(
            @"<?xml version='1.0' encoding='utf-8'?>
            <package xmlns='http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'>
              <metadata>
            <id>testId</id>
              </metadata>
            </package>".NormalizeLineEnding()));
        }
コード例 #7
0
        public void Execute_WithFrameworkAssemblies_ShouldRenderFrameworkAssemblies()
        {
            var destination = new FileStub("output");

            new GenerateNuGetSpecTask(destination)
                .WithFrameworkAssembly("System.ServiceModel", "net40")
                .WithFrameworkAssembly("System.SomethingElse")
                .Execute();

            Assert.That(destination.Content.Trim().NormalizeLineEnding(), Is.EqualTo(
            @"<?xml version='1.0' encoding='utf-8'?>
            <package xmlns='http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'>
              <metadata>
            <frameworkAssemblies>
              <frameworkAssembly assemblyName='System.ServiceModel' targetFramework='net40' />
              <frameworkAssembly assemblyName='System.SomethingElse' />
            </frameworkAssemblies>
              </metadata>
            </package>".NormalizeLineEnding()));
        }
コード例 #8
0
        public void Execute_WithFiles_ShouldRenderFiles()
        {
            var destination = new FileStub("output");

            new GenerateNuGetSpecTask(destination)
                .WithFile(@"bin\Debug\*.dll", "lib")
                .WithFile(@"bin\Debug\*.pdb", "lib")
                .WithFile(@"tools\**\*.*", null, @"**\*.log")
                .Execute();

            Assert.That(destination.Content.Trim().NormalizeLineEnding(), Is.EqualTo(
            @"<?xml version='1.0' encoding='utf-8'?>
            <package xmlns='http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'>
              <metadata>
              </metadata>
              <files>
            <file src='bin\Debug\*.dll' target='lib' />
            <file src='bin\Debug\*.pdb' target='lib' />
            <file src='tools\**\*.*' exclude='**\*.log' />
              </files>
            </package>".NormalizeLineEnding()));
        }