Verify files generated by restore

This commit is contained in:
Mike Harder 2018-04-26 16:42:48 -07:00
parent d7010fb19e
commit 1a4035418a
2 changed files with 33 additions and 2 deletions

View File

@ -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<string> 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);
// }
//}
}
}

View File

@ -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<string> GetObjFiles()
{
return IOUtil.GetFiles(System.IO.Path.Combine(Path, "obj"));
}
}
}