public void SinglePackageShouldBePopulated()
        {
            var reader   = MakeReader();
            var packages = reader.Read(StreamFromString(PackagesFileWithSinglePackage), TempPath());

            var package = packages.FirstOrDefault();

            PackageAssert.IsPopulated(package);
        }
        public void WhenOnePackageCannotBeRead_TheOthersAreStillRead()
        {
            var badVersion = PackagesFileWithTwoPackages.Replace("1.2.3.4", "notaversion", StringComparison.OrdinalIgnoreCase);

            var reader   = MakeReader();
            var packages = reader.Read(StreamFromString(badVersion), TempPath())
                           .ToList();

            Assert.That(packages.Count, Is.EqualTo(1));
            PackageAssert.IsPopulated(packages[0]);
        }
        public void TwoPackagesShouldBePopulated()
        {
            var reader   = MakeReader();
            var packages = reader.Read(StreamFromString(PackagesFileWithTwoPackages), TempPath())
                           .ToList();

            Assert.That(packages, Is.Not.Null);
            Assert.That(packages.Count, Is.EqualTo(2));

            PackageAssert.IsPopulated(packages[0]);
            PackageAssert.IsPopulated(packages[1]);
        }
        public void SinglePackageFromVerboseFormatShouldBePopulated()
        {
            const string verboseFormatVersion =
                @"<Project><ItemGroup><PackageReference Include=""foo""><PrivateAssets>all</PrivateAssets><Version>1.2.3.4</Version></PackageReference></ItemGroup></Project>";

            var reader   = MakeReader();
            var packages = reader.Read(StreamFromString(verboseFormatVersion), TempPath());

            var package = packages.FirstOrDefault();

            PackageAssert.IsPopulated(package);
        }
        public void SinglePackageIsPopulated()
        {
            const string packagesText = @"<PackageReference Include=""foo"" Version=""1.2.3""></PackageReference>";

            var projectFile = Vs2017ProjectFileTemplateWithPackages.Replace("{{Packages}}", packagesText);

            var reader   = MakeReader();
            var packages = reader.Read(StreamFromString(projectFile), _sampleDirectory, _sampleFile);

            var package = packages.FirstOrDefault();

            PackageAssert.IsPopulated(package);
        }
        public void ResultIsReiterable()
        {
            var path = TempPath();

            var reader   = MakeReader();
            var packages = reader.Read(StreamFromString(PackagesFileWithTwoPackages), path);

            foreach (var package in packages)
            {
                PackageAssert.IsPopulated(package);
            }

            Assert.That(packages.Select(p => p.Path), Is.All.EqualTo(path));
        }
        public void PackageWithAssetsVersionShouldBeRead()
        {
            const string noVersion =
                @"<PackageReference Include=""foo""><Version>15.0.26606</Version><ExcludeAssets>all</ExcludeAssets></PackageReference>";

            var projectFile = Vs2017ProjectFileTemplateWithPackages.Replace("{{Packages}}", noVersion);


            var reader   = MakeReader();
            var packages = reader.Read(StreamFromString(projectFile), _sampleDirectory, _sampleFile)
                           .ToList();

            Assert.That(packages.Count, Is.EqualTo(1));
            PackageAssert.IsPopulated(packages[0]);
        }
        public void WhenOnePackageCannotBeRead_TheOthersAreStillRead()
        {
            const string packagesText =
                @"<PackageReference Include=""foo"" Version=""notaversion""></PackageReference>
                  <PackageReference Include=""bar"" Version=""2.3.4""></PackageReference>";

            var projectFile = Vs2017ProjectFileTemplateWithPackages.Replace("{{Packages}}", packagesText);

            var reader   = MakeReader();
            var packages = reader.Read(StreamFromString(projectFile), _sampleDirectory, _sampleFile)
                           .ToList();

            Assert.That(packages.Count, Is.EqualTo(1));
            PackageAssert.IsPopulated(packages[0]);
        }
        public void SinglePackageIsPopulated()
        {
            const string packagesText = @"<PackageReference Include=""foo"" Version=""1.2.3""></PackageReference>";

            var projectFile = Vs2017ProjectFileTemplateWithPackages.Replace("{{Packages}}", packagesText, StringComparison.OrdinalIgnoreCase);

            var reader   = MakeReader();
            var packages = reader.Read(StreamFromString(projectFile), _sampleDirectory, _sampleFile);

            var package = packages.FirstOrDefault();

            PackageAssert.IsPopulated(package);
            Assert.That(package.IsPrerelease, Is.False);
            Assert.That(package.ProjectReferences, Is.Not.Null);
            Assert.That(package.ProjectReferences.Count, Is.EqualTo(1));
        }
        public void WhenTwoPackagesAreRead_TheyArePopulated()
        {
            const string packagesText =
                @"<PackageReference Include=""foo"" Version=""1.2.3""></PackageReference>
                  <PackageReference Include=""bar"" Version=""2.3.4""></PackageReference>";

            var projectFile = Vs2017ProjectFileTemplateWithPackages.Replace("{{Packages}}", packagesText);

            var reader   = MakeReader();
            var packages = reader.Read(StreamFromString(projectFile), _sampleDirectory, _sampleFile)
                           .ToList();

            Assert.That(packages, Is.Not.Null);
            Assert.That(packages.Count, Is.EqualTo(2));
            PackageAssert.IsPopulated(packages[0]);
            PackageAssert.IsPopulated(packages[1]);
        }
        public void WhenTwoPackageDownloadsAreRead_TheyArePopulated()
        {
            const string packagesText =
                @"<PackageDownload Include=""foo"" Version=""[1.2.3]""></PackageDownload>
                  <PackageDownload Include=""bar"" Version=""[2.3.4]""></PackageDownload>";

            var projectFile = Vs2017ProjectFileTemplateWithPackages.Replace("{{Packages}}", packagesText, StringComparison.OrdinalIgnoreCase);

            var reader   = MakeReader();
            var packages = reader.Read(StreamFromString(projectFile), _sampleDirectory, _sampleFile)
                           .ToList();

            Assert.That(packages, Is.Not.Null);
            Assert.That(packages.Count, Is.EqualTo(2));
            PackageAssert.IsPopulated(packages[0]);
            PackageAssert.IsPopulated(packages[1]);
        }