Пример #1
0
        public LocalPackageSearchMetadataFixture()
        {
            var pkgId  = new PackageIdentity("nuget.psm.test", new NuGetVersion(0, 0, 1));
            var pkg    = new SimpleTestPackageContext(pkgId.Id, pkgId.Version.ToNormalizedString());
            var nuspec = NuspecBuilder.Create()
                         .WithPackageId(pkgId.Id)
                         .WithPackageVersion(pkgId.Version.ToNormalizedString())
                         .WithIcon("icon.png")
                         .Build();

            pkg.Nuspec = XDocument.Parse(nuspec.ToString());

            _testDirectory = TestDirectory.Create();

            SimpleTestPackageUtility.CreatePackagesAsync(_testDirectory.Path, pkg).Wait();
            var pkgPath = Path.Combine(_testDirectory.Path, $"{pkgId.Id}.{pkgId.Version.ToNormalizedString()}.nupkg");
            var info    = new LocalPackageInfo(
                identity: pkgId,
                path: pkgPath,
                lastWriteTimeUtc: DateTime.UtcNow,
                nuspec: new Lazy <Packaging.NuspecReader>(() => {
                var reader = new PackageArchiveReader(pkgPath);
                return(reader.NuspecReader);
            }),
                getPackageReader: () => new PackageArchiveReader(pkgPath));

            TestData = new LocalPackageSearchMetadata(info);
        }
        /// <summary>
        /// Creates the TestDirectory and all the files
        /// </summary>
        /// <returns>A <c>TestDirectory</c> object with the file structure created</returns>
        public TestDirectory Build()
        {
            TestDirectory testDirectory = TestDirectory.Create();

            BaseDir = testDirectory.Path;

            CreateFiles();

            if (NuspecBuilder != null)
            {
                var dir = Path.GetDirectoryName(NuspecPath);
                Directory.CreateDirectory(dir);
                File.WriteAllText(NuspecPath, NuspecBuilder.Build().ToString());
            }

            return(testDirectory);
        }
 public TestDirectoryBuilder WithNuspec(NuspecBuilder nuspecBuilder, string filepath = "Package.nuspec")
 {
     NuspecBuilder = nuspecBuilder;
     NuspecFile    = filepath;
     return(this);
 }
Пример #4
0
        /// <summary>
        /// Factory method
        /// </summary>
        /// <returns>A <c>NuspecBuilder</c> factory object</returns>
        public static NuspecBuilder Create()
        {
            var builder = new NuspecBuilder();

            return(builder);
        }