Exemplo n.º 1
0
        public void Packages()
        {
            dir.Packages.Should(Be.Empty);

            // if we copy an UnpackedPackage into our PackageDirectory, it should show up!
            Path.Combine(dir.PackageDirectory, "MarkdownSharp.1.13.0.0").AsDir().Exists().Should(Be.False);
            new UnpackedNupkg(PathToContent("packages/MarkdownSharp.1.13.0.0")).Copy(dir.PackageDirectory);
            Path.Combine(dir.PackageDirectory, "MarkdownSharp.1.13.0.0").AsDir().Exists().Should(Be.True);

            dir.Packages.Count.ShouldEqual(1);

            var package = dir.Packages.First();

            package.Id.ShouldEqual("MarkdownSharp");
            package.Should(Be.InstanceOf(typeof(MooDirPackage)));
            (package as MooDirPackage).Unpacked.Should(Be.InstanceOf(typeof(UnpackedNupkg)));
            (package as MooDirPackage).Unpacked.Path.ShouldEqual(Path.Combine(dir.PackageDirectory, "MarkdownSharp.1.13.0.0"));
            (package as MooDirPackage).Nupkg.Should(Be.Null);

            // if we put the cached nupkg where it's supposed to be, we should see it ...
            Path.Combine(dir.CacheDirectory, "MarkdownSharp.1.13.0.0.nupkg").AsFile().Exists().Should(Be.False);
            new Nupkg(PathToContent("packages/MarkdownSharp.1.13.0.0.nupkg")).Copy(dir.CacheDirectory);
            Path.Combine(dir.CacheDirectory, "MarkdownSharp.1.13.0.0.nupkg").AsFile().Exists().Should(Be.True);

            package = dir.Packages.First();
            package.Id.ShouldEqual("MarkdownSharp");
            package.Should(Be.InstanceOf(typeof(MooDirPackage)));
            (package as MooDirPackage).Unpacked.Should(Be.InstanceOf(typeof(UnpackedNupkg)));
            (package as MooDirPackage).Unpacked.Path.ShouldEqual(Path.Combine(dir.PackageDirectory, "MarkdownSharp.1.13.0.0"));
            (package as MooDirPackage).Nupkg.Should(Be.InstanceOf(typeof(Nupkg)));
            (package as MooDirPackage).Nupkg.Path.ShouldEqual(Path.Combine(dir.CacheDirectory, "MarkdownSharp.1.13.0.0.nupkg"));
        }
Exemplo n.º 2
0
        public void Can_add_sources()
        {
            Directory.CreateDirectory(PathToTemp("mydir"));
            var mydir = new MooDir(PathToTemp("mydir")).Initialize();

            // default has no sources (currently)
            mydir.SourceFile.Exists().Should(Be.True);             // there should be a template, but no sources
            mydir.SourceFile.Read().ShouldContain("MooGet");       // should should be some text (commented out)
            mydir.SourceFile.Sources.Count.ShouldEqual(0);
            mydir.Sources.Count.ShouldEqual(0);

            // add a source by adding to the file's text [example with name]
            //mydir.SourceFile.AppendLine("Cool Source " + PathToContent("packages"));
            mydir.SourceFile.Add("Cool Source", PathToContent("packages"));
            mydir.Sources.Count.ShouldEqual(1);
            mydir.Sources.First().Name.ShouldEqual("Cool Source");
            mydir.Sources.First().Path.ShouldEqual(PathToContent("packages"));
            mydir.Sources.First().Should(Be.InstanceOf(typeof(DirectoryOfNupkg)));

            // add a source by adding to the file's text [example without name]
            //mydir.SourceFile.AppendLine(PathToContent("more_packages"));
            mydir.SourceFile.Add(PathToContent("more_packages"));
            mydir.Sources.Count.ShouldEqual(2);
            mydir.Sources.First().Name.ShouldEqual("Cool Source");
            mydir.Sources.First().Path.ShouldEqual(PathToContent("packages"));
            mydir.Sources.First().Should(Be.InstanceOf(typeof(DirectoryOfNupkg)));
            mydir.Sources.Last().Name.Should(Be.Null);
            mydir.Sources.Last().Path.ShouldEqual(PathToContent("more_packages"));
            mydir.Sources.Last().Should(Be.InstanceOf(typeof(DirectoryOfNupkg)));

            mydir.SourceFile.Read().ShouldContain("MooGet");             // this should still be in the file
        }
Exemplo n.º 3
0
        public void Push()
        {
            dir.Packages.Should(Be.Empty);

            var pkg = dir.Push(new Nupkg(PathToContent("packages/MarkdownSharp.1.13.0.0.nupkg")));

            // check the IPackage that we get back
            pkg.Should(Be.InstanceOf(typeof(MooDirPackage)));
            pkg.Id.ShouldEqual("MarkdownSharp");
            pkg.Source.ShouldEqual(dir);
            (pkg as MooDirPackage).Nupkg.Path.ShouldEqual(Path.Combine(dir.CacheDirectory, "MarkdownSharp-1.13.0.0.nupkg"));
            (pkg as MooDirPackage).Unpacked.Path.ShouldEqual(Path.Combine(dir.PackageDirectory, "MarkdownSharp-1.13.0.0"));

            dir.Packages.Count.ShouldEqual(1);
            dir.Packages.First().Id.ShouldEqual("MarkdownSharp");
            dir.BinDirectory.AsDir().Files().Count.ShouldEqual(0);

            dir.Push(new Nupkg(PathToContent("package_working_directories/just-a-tool-1.0.0.0.nupkg")));

            dir.Packages.Count.ShouldEqual(2);
            dir.Packages.Ids().ShouldEqual(new List <string> {
                "MarkdownSharp", "just-a-tool"
            });

            dir.BinDirectory.AsDir().Files().Count.ShouldEqual(2);             // tool.exe should have a 'tool' script and a 'tool.bat' script
            dir.BinDirectory.AsDir().Files().Select(f => f.Name()).ToList().ShouldEqual(new List <string> {
                "tool", "tool.bat"
            });
        }
Exemplo n.º 4
0
        public void Unpack()
        {
            var tool = new Nupkg(PathToContent("package_working_directories/just-a-tool-1.0.0.0.nupkg"));

            // if extract to existing directory, extracts into it
            var dir = PathToTemp("ExtractHere").AsDir().Create();

            PathToTemp("ExtractHere").AsDir().Exists().Should(Be.True);
            PathToTemp("ExtractHere", "just-a-tool-1.0.0.0").AsDir().Exists().Should(Be.False);
            PathToTemp("ExtractHere", "just-a-tool-1.0.0.0", "tools").AsDir().Exists().Should(Be.False);

            var unpacked = tool.Unpack(dir.Path);

            unpacked.Should(Be.InstanceOf(typeof(UnpackedNupkg)));
            unpacked.Path.ShouldEqual(PathToTemp("ExtractHere", "just-a-tool-1.0.0.0"));
            unpacked.Id.ShouldEqual("just-a-tool");
            (unpacked as UnpackedNupkg).Nuspec.Path.ShouldEqual(PathToTemp("ExtractHere", "just-a-tool-1.0.0.0", "just-a-tool.nuspec"));
            unpacked.Tools.ShouldEqual(new List <string> {
                PathToTemp("ExtractHere", "just-a-tool-1.0.0.0", "tools", "tool.exe")
            });

            PathToTemp("ExtractHere").AsDir().Exists().Should(Be.True);
            PathToTemp("ExtractHere", "just-a-tool-1.0.0.0").AsDir().Exists().Should(Be.True);
            PathToTemp("ExtractHere", "just-a-tool-1.0.0.0", "tools").AsDir().Exists().Should(Be.True);
            PathToTemp("ExtractHere", "just-a-tool-1.0.0.0", "just-a-tool.nuspec").AsFile().Exists().Should(Be.True);
            PathToTemp("ExtractHere", "just-a-tool-1.0.0.0", "tools", "tool.exe").AsFile().Exists().Should(Be.True);

            // if extract to new directory, extract exactly there
            PathToTemp("Exact_Dir").AsDir().Exists().Should(Be.False);
            PathToTemp("Exact_Dir", "tools").AsDir().Exists().Should(Be.False);

            unpacked = tool.Unpack(PathToTemp("Exact_Dir"));

            unpacked.Should(Be.InstanceOf(typeof(UnpackedNupkg)));
            unpacked.Path.ShouldEqual(PathToTemp("Exact_Dir"));
            unpacked.Id.ShouldEqual("just-a-tool");
            (unpacked as UnpackedNupkg).Nuspec.Path.ShouldEqual(PathToTemp("Exact_Dir", "just-a-tool.nuspec"));
            unpacked.Tools.ShouldEqual(new List <string> {
                PathToTemp("Exact_Dir", "tools", "tool.exe")
            });

            PathToTemp("Exact_Dir").AsDir().Exists().Should(Be.True);
            PathToTemp("Exact_Dir", "tools").AsDir().Exists().Should(Be.True);
            PathToTemp("Exact_Dir", "just-a-tool.nuspec").AsFile().Exists().Should(Be.True);
            PathToTemp("Exact_Dir", "tools", "tool.exe").AsFile().Exists().Should(Be.True);

            // it should name the directory using the package id and version, not the name of the .nupkg file ...
            PathToTemp("MarkdownSharp-1.13.0.0").AsDir().Exists().Should(Be.False);
            new Nupkg(PathToContent("packages/unnamed.nupkg")).Unpack(PathToTemp(""));
            PathToTemp("MarkdownSharp-1.13.0.0").AsDir().Exists().Should(Be.True);
        }
Exemplo n.º 5
0
        public void Language_and_Locale()
        {
            details.Language.Should(Be.Null);
            details.Locale.Should(Be.Null);

            details.Language = "en-US";

            details.Language.ShouldEqual("en-US");
            details.Locale.Should(Be.InstanceOf(typeof(System.Globalization.CultureInfo)));
            details.Locale.DisplayName.ShouldEqual("English (United States)");
            details.Locale.ToString().ShouldEqual("en-US");

            details.Locale = new System.Globalization.CultureInfo("en-GB");
            details.Locale.ToString().ShouldEqual("en-GB");
            details.Locale.DisplayName.ShouldEqual("English (United Kingdom)");
            details.Language.ShouldEqual("en-GB");
        }
Exemplo n.º 6
0
        public void can_TextWriter_for_STDOUT_and_STDERR()
        {
            var response = new Response();

            response.STDOUT.Should(Be.InstanceOf(typeof(StringBuilder)));
            response.STDERR.Should(Be.InstanceOf(typeof(StringBuilder)));

            response.Out.Write("hello");

            response.OutputText.ShouldEqual("hello");
            response.ErrorText.ShouldEqual("");

            response.Error.Write("boom!");

            response.OutputText.ShouldEqual("hello");
            response.ErrorText.ShouldEqual("boom!");
        }
Exemplo n.º 7
0
        public void Push()
        {
            dir.Packages.Should(Be.Empty);

            var pkg = dir.Push(new Nupkg(PathToContent("packages/MarkdownSharp.1.13.0.0.nupkg")));

            pkg.Should(Be.InstanceOf(typeof(Nupkg)));
            pkg.Id.ShouldEqual("MarkdownSharp");
            (pkg as Nupkg).Path.ShouldEqual(System.IO.Path.Combine(dir.Path, "MarkdownSharp-1.13.0.0.nupkg"));

            dir.Packages.Count.ShouldEqual(1);
            dir.Packages.First().Id.ShouldEqual("MarkdownSharp");

            dir.Push(new Nupkg(PathToContent("package_working_directories/just-a-tool-1.0.0.0.nupkg")));

            dir.Packages.Count.ShouldEqual(2);
            dir.Packages.Ids().ShouldEqual(new List <string> {
                "MarkdownSharp", "just-a-tool"
            });
        }