public void CanCreate_MSBuildProjectIsNull_DoesNotThrowNullReferenceException()
        {
            var dotNetCoreProject = CreateDotNetCoreProject();

            dotNetCoreProject.Dispose();

            bool result = false;

            Assert.DoesNotThrow(() => {
                result = DotNetCoreNuGetProject.CanCreate(dotNetCoreProject);
            });

            Assert.IsNull(dotNetCoreProject.MSBuildProject);
            Assert.IsFalse(result);
        }
        public async Task GetPackageSpecsAsync_NewProject_BaseIntermediatePathUsedForProjectAssetsJsonFile()
        {
            string projectFile = Util.GetSampleProject("NetStandardXamarinForms", "NetStandardXamarinForms", "NetStandardXamarinForms.csproj");

            using (var project = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile)) {
                dependencyGraphCacheContext = new DependencyGraphCacheContext();
                var nugetProject = new DotNetCoreNuGetProject(project);
                var specs        = await nugetProject.GetPackageSpecsAsync(dependencyGraphCacheContext);

                var spec = specs.Single();

                Assert.AreEqual(projectFile, spec.FilePath);
                Assert.AreEqual("NetStandardXamarinForms", spec.Name);
                Assert.AreEqual("1.0.0", spec.Version.ToString());
                Assert.AreEqual(ProjectStyle.PackageReference, spec.RestoreMetadata.ProjectStyle);
                Assert.AreEqual("NetStandardXamarinForms", spec.RestoreMetadata.ProjectName);
                Assert.AreEqual(projectFile, spec.RestoreMetadata.ProjectPath);
                Assert.AreEqual(projectFile, spec.RestoreMetadata.ProjectUniqueName);
                Assert.AreSame(spec, dependencyGraphCacheContext.PackageSpecCache[projectFile]);
                Assert.AreEqual("netstandard1.0", spec.RestoreMetadata.OriginalTargetFrameworks.Single());
            }
        }
        public async Task GetPackageSpecsAsync_DotNetCliTool_PackageSpecsIncludeDotNetCliToolReference()
        {
            string projectFile = Util.GetSampleProject("dotnet-cli-tool", "dotnet-cli-tool-netcore.csproj");

            using (var project = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile)) {
                dependencyGraphCacheContext = new DependencyGraphCacheContext();
                var nugetProject = new DotNetCoreNuGetProject(project);
                var specs        = await nugetProject.GetPackageSpecsAsync(dependencyGraphCacheContext);

                var projectSpec       = specs.FirstOrDefault(s => s.RestoreMetadata.ProjectStyle == ProjectStyle.PackageReference);
                var dotNetCliToolSpec = specs.FirstOrDefault(s => s.RestoreMetadata.ProjectStyle == ProjectStyle.DotnetCliTool);

                Assert.AreEqual(2, specs.Count);
                Assert.AreEqual(projectFile, projectSpec.FilePath);
                Assert.AreEqual("dotnet-cli-tool-netcore", projectSpec.Name);
                Assert.AreEqual("dotnet-cli-tool-netcore", projectSpec.RestoreMetadata.ProjectName);
                Assert.AreEqual(projectFile, projectSpec.RestoreMetadata.ProjectPath);
                Assert.AreEqual(projectFile, projectSpec.RestoreMetadata.ProjectUniqueName);
                Assert.AreSame(projectSpec, dependencyGraphCacheContext.PackageSpecCache [projectFile]);
                Assert.AreEqual("bundlerminifier.core-netcoreapp2.1-[2.9.406, )", dotNetCliToolSpec.Name);
                Assert.AreEqual(projectFile, dotNetCliToolSpec.RestoreMetadata.ProjectPath);
                Assert.AreSame(dotNetCliToolSpec, dependencyGraphCacheContext.PackageSpecCache [dotNetCliToolSpec.Name]);
            }
        }