From 1a4035418a80de7c6fb2f6be6e5ca2bde768ecfd Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Thu, 26 Apr 2018 16:42:48 -0700 Subject: [PATCH] Verify files generated by restore --- AspNetCoreSdkTests/TemplateTests.cs | 24 ++++++++++++++++++++++++ AspNetCoreSdkTests/Util/DotNetContext.cs | 11 +++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/AspNetCoreSdkTests/TemplateTests.cs b/AspNetCoreSdkTests/TemplateTests.cs index c56d0fc453..3b2840be67 100644 --- a/AspNetCoreSdkTests/TemplateTests.cs +++ b/AspNetCoreSdkTests/TemplateTests.cs @@ -1,5 +1,6 @@ using AspNetCoreSdkTests.Util; using NUnit.Framework; +using System.Collections.Generic; namespace AspNetCoreSdkTests { @@ -10,11 +11,34 @@ namespace AspNetCoreSdkTests [TestCaseSource(typeof(TestData), nameof(TestData.AllTemplates))] public void Restore(Template template, NuGetConfig nuGetConfig) { + IEnumerable objFiles; using (var context = new DotNetContext()) { context.New(template, restore: false); context.Restore(nuGetConfig); + objFiles = context.GetObjFiles(); } + + var t = template.ToString().ToLowerInvariant(); + var expectedObjFiles = new[] { + $"{t}.csproj.nuget.cache", + $"{t}.csproj.nuget.g.props", + $"{t}.csproj.nuget.g.targets", + "project.assets.json", + }; + + CollectionAssert.AreEquivalent(expectedObjFiles, objFiles); } + + //[Test] + //[TestCaseSource(typeof(TestData), nameof(TestData.AllTemplates))] + //public void Build(Template template, NuGetConfig nuGetConfig) + //{ + // using (var context = new DotNetContext()) + // { + // context.New(template, restore: false); + // context.Restore(nuGetConfig); + // } + //} } } diff --git a/AspNetCoreSdkTests/Util/DotNetContext.cs b/AspNetCoreSdkTests/Util/DotNetContext.cs index 12209a2d1d..b33151fc0a 100644 --- a/AspNetCoreSdkTests/Util/DotNetContext.cs +++ b/AspNetCoreSdkTests/Util/DotNetContext.cs @@ -1,15 +1,22 @@ -namespace AspNetCoreSdkTests.Util +using System.Collections.Generic; + +namespace AspNetCoreSdkTests.Util { public class DotNetContext : TempDir { public string New(Template template, bool restore) { - return DotNet.New(template.ToString(), Path, restore); + return DotNet.New(template.ToString().ToLowerInvariant(), Path, restore); } public string Restore(NuGetConfig config) { return DotNet.Restore(Path, config); } + + public IEnumerable GetObjFiles() + { + return IOUtil.GetFiles(System.IO.Path.Combine(Path, "obj")); + } } }