diff --git a/AspNetCoreSdkTests/Util/AssemblyInfo.cs b/AspNetCoreSdkTests/AssemblyInfo.cs similarity index 100% rename from AspNetCoreSdkTests/Util/AssemblyInfo.cs rename to AspNetCoreSdkTests/AssemblyInfo.cs diff --git a/AspNetCoreSdkTests/NuGetPackageSource.cs b/AspNetCoreSdkTests/NuGetPackageSource.cs index 206102f222..a20903007b 100644 --- a/AspNetCoreSdkTests/NuGetPackageSource.cs +++ b/AspNetCoreSdkTests/NuGetPackageSource.cs @@ -1,9 +1,39 @@ -namespace AspNetCoreSdkTests +using System; + +namespace AspNetCoreSdkTests { - public enum NuGetPackageSource + public class NuGetPackageSource { - None, - NuGetOrg, - EnvironmentVariable, + public static NuGetPackageSource None { get; } = new NuGetPackageSource + { + Name = nameof(None), + SourceArgumentLazy = new Lazy(string.Empty), + }; + + public static NuGetPackageSource NuGetOrg { get; } = new NuGetPackageSource + { + Name = nameof(NuGetOrg), + SourceArgumentLazy = new Lazy("--source https://api.nuget.org/v3/index.json"), + }; + + public static NuGetPackageSource EnvironmentVariable { get; } = new NuGetPackageSource + { + Name = nameof(EnvironmentVariable), + SourceArgumentLazy = new Lazy(() => $"--source {GetPackageSourceFromEnvironment()}"), + }; + + private NuGetPackageSource() { } + + public string Name { get; private set; } + public string SourceArgument => SourceArgumentLazy.Value; + private Lazy SourceArgumentLazy { get; set; } + + public override string ToString() => Name; + + private static string GetPackageSourceFromEnvironment() + { + return Environment.GetEnvironmentVariable("NUGET_PACKAGE_SOURCE") ?? + throw new InvalidOperationException("Environment variable NUGET_PACKAGE_SOURCE is required but not set"); + } } } diff --git a/AspNetCoreSdkTests/SelfContained.cs b/AspNetCoreSdkTests/SelfContained.cs new file mode 100644 index 0000000000..e149f28df6 --- /dev/null +++ b/AspNetCoreSdkTests/SelfContained.cs @@ -0,0 +1,31 @@ +using AspNetCoreSdkTests.Templates; +using NUnit.Framework; +using System.Collections.Generic; + +namespace AspNetCoreSdkTests +{ + [TestFixture] + public class SelfContained + { + [Test] + [TestCaseSource(nameof(RestoreData))] + public void Restore(Template template) + { + CollectionAssert.AreEquivalent(template.ExpectedObjFilesAfterRestore, template.ObjFilesAfterRestore); + } + + public static IEnumerable