Move test data into test class
This commit is contained in:
parent
dd88f5d046
commit
823baabb8f
|
|
@ -1,35 +0,0 @@
|
|||
using AspNetCoreSdkTests.Templates;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AspNetCoreSdkTests
|
||||
{
|
||||
public static class TemplateData
|
||||
{
|
||||
public static IEnumerable<TestCaseData> Restore = new TestCaseData[]
|
||||
{
|
||||
new TestCaseData(Template.GetInstance<ClassLibraryTemplate>(NuGetConfig.Empty)),
|
||||
new TestCaseData(Template.GetInstance<ConsoleApplicationTemplate>(NuGetConfig.Empty)),
|
||||
|
||||
// Offline restore currently not supported for RazorClassLibrary template (https://github.com/aspnet/Universe/issues/1123)
|
||||
new TestCaseData(Template.GetInstance<RazorClassLibraryTemplate>(NuGetConfig.NuGetOrg)),
|
||||
|
||||
new TestCaseData(Template.GetInstance<WebTemplate>(NuGetConfig.Empty)),
|
||||
new TestCaseData(Template.GetInstance<RazorTemplate>(NuGetConfig.Empty)),
|
||||
new TestCaseData(Template.GetInstance<MvcTemplate>(NuGetConfig.Empty)),
|
||||
new TestCaseData(Template.GetInstance<AngularTemplate>(NuGetConfig.Empty)),
|
||||
new TestCaseData(Template.GetInstance<ReactTemplate>(NuGetConfig.Empty)),
|
||||
new TestCaseData(Template.GetInstance<ReactReduxTemplate>(NuGetConfig.Empty)),
|
||||
new TestCaseData(Template.GetInstance<WebApiTemplate>(NuGetConfig.Empty)),
|
||||
};
|
||||
|
||||
public static IEnumerable<TestCaseData> Build => Restore;
|
||||
|
||||
public static IEnumerable<TestCaseData> Publish => Restore;
|
||||
|
||||
public static IEnumerable<TestCaseData> Run = Restore.Where(d => ((Template)d.Arguments[0]).Type == TemplateType.WebApplication);
|
||||
|
||||
public static IEnumerable<TestCaseData> Exec => Run;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
using AspNetCoreSdkTests.Templates;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
||||
namespace AspNetCoreSdkTests
|
||||
|
|
@ -8,28 +10,28 @@ namespace AspNetCoreSdkTests
|
|||
public class TemplateTests
|
||||
{
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TemplateData), nameof(TemplateData.Restore))]
|
||||
[TestCaseSource(nameof(RestoreData))]
|
||||
public void Restore(Template template)
|
||||
{
|
||||
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterRestore, template.ObjFilesAfterRestore);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TemplateData), nameof(TemplateData.Build))]
|
||||
[TestCaseSource(nameof(BuildData))]
|
||||
public void Build(Template template)
|
||||
{
|
||||
CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterBuild, template.ObjFilesAfterBuild);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TemplateData), nameof(TemplateData.Publish))]
|
||||
[TestCaseSource(nameof(PublishData))]
|
||||
public void Publish(Template template)
|
||||
{
|
||||
CollectionAssert.AreEquivalent(template.ExpectedFilesAfterPublish, template.FilesAfterPublish);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TemplateData), nameof(TemplateData.Run))]
|
||||
[TestCaseSource(nameof(RunData))]
|
||||
public void Run(Template template)
|
||||
{
|
||||
Assert.AreEqual(HttpStatusCode.OK, template.HttpResponseAfterRun.StatusCode);
|
||||
|
|
@ -37,11 +39,36 @@ namespace AspNetCoreSdkTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
[TestCaseSource(typeof(TemplateData), nameof(TemplateData.Exec))]
|
||||
[TestCaseSource(nameof(ExecData))]
|
||||
public void Exec(Template template)
|
||||
{
|
||||
Assert.AreEqual(HttpStatusCode.OK, template.HttpResponseAfterExec.StatusCode);
|
||||
Assert.AreEqual(HttpStatusCode.OK, template.HttpsResponseAfterExec.StatusCode);
|
||||
}
|
||||
|
||||
public static IEnumerable<Template> RestoreData = new[]
|
||||
{
|
||||
Template.GetInstance<ClassLibraryTemplate>(NuGetConfig.Empty),
|
||||
Template.GetInstance<ConsoleApplicationTemplate>(NuGetConfig.Empty),
|
||||
|
||||
// Offline restore currently not supported for RazorClassLibrary template (https://github.com/aspnet/Universe/issues/1123)
|
||||
Template.GetInstance<RazorClassLibraryTemplate>(NuGetConfig.NuGetOrg),
|
||||
|
||||
Template.GetInstance<WebTemplate>(NuGetConfig.Empty),
|
||||
Template.GetInstance<RazorTemplate>(NuGetConfig.Empty),
|
||||
Template.GetInstance<MvcTemplate>(NuGetConfig.Empty),
|
||||
Template.GetInstance<AngularTemplate>(NuGetConfig.Empty),
|
||||
Template.GetInstance<ReactTemplate>(NuGetConfig.Empty),
|
||||
Template.GetInstance<ReactReduxTemplate>(NuGetConfig.Empty),
|
||||
Template.GetInstance<WebApiTemplate>(NuGetConfig.Empty),
|
||||
};
|
||||
|
||||
public static IEnumerable<Template> BuildData => RestoreData;
|
||||
|
||||
public static IEnumerable<Template> PublishData => RestoreData;
|
||||
|
||||
public static IEnumerable<Template> RunData = RestoreData.Where(t => t.Type == TemplateType.WebApplication);
|
||||
|
||||
public static IEnumerable<Template> ExecData => RunData;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue