Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do-not-merge] Added sample verify folder test #5163

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.TemplateEngine.Abstractions;
using Microsoft.TemplateEngine.Abstractions.TemplateFiltering;
using Microsoft.TemplateEngine.Core;
using Microsoft.TemplateEngine.IDE.IntegrationTests.Utils;
using Microsoft.TemplateEngine.TestHelper;
using Microsoft.TemplateEngine.Utils;
using VerifyXunit;
using Xunit;

namespace Microsoft.TemplateEngine.IDE.IntegrationTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.TemplateEngine.Edge.Template;
using Microsoft.TemplateEngine.TestHelper;
using ITemplateMatchInfo = Microsoft.TemplateEngine.Abstractions.TemplateFiltering.ITemplateMatchInfo;
using WellKnownSearchFilters = Microsoft.TemplateEngine.Utils.WellKnownSearchFilters;

namespace Microsoft.TemplateEngine.IDE.IntegrationTests
{
public class TemplatesTests : BootstrapperTestBase, IClassFixture<PackageManager>
{
private PackageManager _packageManager;

public TemplatesTests(PackageManager packageManager)
{
_packageManager = packageManager;
}

[Fact]
internal async Task ConsoleBasicTest()
{
using Bootstrapper bootstrapper = GetBootstrapper();
string packageLocation = await _packageManager.GetNuGetPackage("Microsoft.DotNet.Common.ProjectTemplates.5.0").ConfigureAwait(false);
await InstallTemplateAsync(bootstrapper, packageLocation).ConfigureAwait(false);

string output = TestUtils.CreateTemporaryFolder();
IReadOnlyList<ITemplateMatchInfo> foundTemplates = await bootstrapper.GetTemplatesAsync(new[] { WellKnownSearchFilters.NameFilter("console") }).ConfigureAwait(false);
ITemplateCreationResult result = await bootstrapper.CreateAsync(foundTemplates[0].Info, "test", output, new Dictionary<string, string?>()).ConfigureAwait(false);
Assert.Equal(2, result.CreationResult?.PrimaryOutputs.Count);
Assert.Equal(2, result.CreationResult?.PostActions.Count);

//return VerifyFolder(output)
// .Ignore("obj/**/*")
// .Ignore("bin/**/*")
// .ScrubGuids()
// .AddScrubber(MyCustomScrubber);

//content of the folder is:
// - obj
// - Program.cs
// - test.csproj
}

[Fact]
internal async Task WebAppBasicTest()
{
using Bootstrapper bootstrapper = GetBootstrapper();
string packageLocation = await _packageManager.GetNuGetPackage("Microsoft.DotNet.Web.ProjectTemplates.5.0").ConfigureAwait(false);
await InstallTemplateAsync(bootstrapper, packageLocation).ConfigureAwait(false);

string output = TestUtils.CreateTemporaryFolder();
IReadOnlyList<ITemplateMatchInfo> foundTemplates = await bootstrapper.GetTemplatesAsync(new[] { WellKnownSearchFilters.NameFilter("webapp") }).ConfigureAwait(false);
ITemplateCreationResult result = await bootstrapper.CreateAsync(foundTemplates[0].Info, "test", output, new Dictionary<string, string?>()).ConfigureAwait(false);
Assert.Equal(1, result.CreationResult?.PrimaryOutputs.Count);
Assert.Equal(1, result.CreationResult?.PostActions.Count);

//return VerifyFolder(output)
// .Ignore("obj/**/*")
// .Ignore("bin/**/*")
// .DoNotCompareContent(wwwroot/**/*)
// .ScrubGuids()
// .AddScrubber(MyCustomScrubber);

//content of the folder is:
// - obj
// - Pages
// - Properties
// - wwwroot
// - appsettings.Development.json
// - appsettings.json
// - Program.cs
// - Startup.cs
// - test.csproj
}
}
}