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 }
public void can_initialize() { var mooDir = new MooDir(PathToTemp("FooBar")); PathToTemp("FooBar").AsDir().Exists().Should(Be.False); mooDir.Initialize(); PathToTemp("FooBar").AsDir().Exists().Should(Be.True); PathToTemp("FooBar", "packages").AsDir().Exists().Should(Be.True); // unpacked packages go here PathToTemp("FooBar", "cache").AsDir().Exists().Should(Be.True); // .nupkg's are cached here PathToTemp("FooBar", "bin").AsDir().Exists().Should(Be.True); // this should be added to the user's PATH to run tools mooDir.PackageDirectory.ShouldEqual(PathToTemp("FooBar", "packages")); mooDir.CacheDirectory.ShouldEqual(PathToTemp("FooBar", "cache")); mooDir.BinDirectory.ShouldEqual(PathToTemp("FooBar", "bin")); }
public void Install() { Directory.CreateDirectory(PathToTemp("mydir")); var mydir = new MooDir(PathToTemp("mydir")).Initialize(); mydir.Packages.Should(Be.Empty); // if we don't provide any sources, it can't find the package we're talking about ... Should.Throw <PackageNotFoundException>("Package not found: FluentNHibernate", () => { mydir.Install(new PackageDependency("FluentNHibernate")); }); // we find the package we're talking about, but we're missing one of the dependencies Should.Throw <MissingDependencyException>("No packages were found that satisfy these dependencies: Iesi.Collections >= 1.0.1, Castle.DynamicProxy >= 2.1.0", () => { mydir.Install(new PackageDependency("FluentNHibernate"), morePackages); }); mydir.Packages.Should(Be.Empty); // check the dependencies that we're going to install (assuming Install() calls FindDependencies) var dependencies = Source.FindDependencies(morePackages.Get(new PackageDependency("FluentNHibernate")), morePackages, morePackageDependencies); dependencies.Count.ShouldEqual(6); dependencies.Select(pkg => pkg.IdAndVersion()).ToList().ShouldContainAll( "NHibernate-2.1.2.4000", "log4net-1.2.10", "Iesi.Collections-1.0.1", "Antlr-3.1.1", "Castle.DynamicProxy-2.1.0", "Castle.Core-1.1.0", "log4net-1.2.10" ); // Inspect their sources to see that some come from 1, some come from another dependencies.First(d => d.Id == "NHibernate").Source.ShouldEqual(morePackages); dependencies.First(d => d.Id == "log4net").Source.ShouldEqual(morePackages); dependencies.First(d => d.Id == "Antlr").Source.ShouldEqual(morePackages); dependencies.First(d => d.Id == "Castle.Core").Source.ShouldEqual(morePackages); dependencies.First(d => d.Id == "Iesi.Collections").Source.ShouldEqual(morePackageDependencies); dependencies.First(d => d.Id == "Castle.DynamicProxy").Source.ShouldEqual(morePackageDependencies); mydir.Install(new PackageDependency("FluentNHibernate"), morePackages, morePackageDependencies); mydir.Packages.Count.ShouldEqual(7); mydir.Packages.Select(pkg => pkg.IdAndVersion()).ToList().ShouldContainAll( "NHibernate-2.1.2.4000", "log4net-1.2.10", "Iesi.Collections-1.0.1", "Antlr-3.1.1", "Castle.DynamicProxy-2.1.0", "Castle.Core-1.1.0", "FluentNHibernate-1.1.0.694" ); }
public void Can_remove_sources() { Directory.CreateDirectory(PathToTemp("mydir")); var mydir = new MooDir(PathToTemp("mydir")).Initialize(); mydir.SourceFile.Add("Cool Source", PathToContent("packages")); mydir.SourceFile.Add(PathToContent("more_packages")); mydir.Sources.Count.ShouldEqual(2); // remove by name mydir.SourceFile.Remove("Cool Source"); mydir.Sources.Count.ShouldEqual(1); mydir.Sources.First().Path.ShouldEqual(PathToContent("more_packages")); // remove by path mydir.SourceFile.Remove(PathToContent("more_packages")); mydir.Sources.Count.ShouldEqual(0); }
public void Uninstall_with_dependencies() { Directory.CreateDirectory(PathToTemp("mydir")); var mydir = new MooDir(PathToTemp("mydir")).Initialize(); mydir.Install(new PackageDependency("FluentNHibernate"), morePackages, morePackageDependencies); mydir.Packages.Count.ShouldEqual(7); mydir.Packages.Select(pkg => pkg.IdAndVersion()).ToList().ShouldContainAll( "NHibernate-2.1.2.4000", "log4net-1.2.10", "Iesi.Collections-1.0.1", "Antlr-3.1.1", "Castle.DynamicProxy-2.1.0", "Castle.Core-1.1.0", "FluentNHibernate-1.1.0.694" ); mydir.Uninstall(new PackageDependency("FluentNHibernate"), true).Should(Be.True); mydir.Packages.Count.ShouldEqual(0); mydir.Uninstall(new PackageDependency("FluentNHibernate"), true).Should(Be.False); mydir.Packages.Count.ShouldEqual(0); }
public void Before() { base.BeforeEach(); dir = new MooDir(PathToTemp("MyMooDir")); dir.Initialize(); }