Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vlada-shubina committed Jun 30, 2021
1 parent d5b2f5e commit 25c4f57
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/dotnet-new3.UnitTests/DotnetNewInstantiate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,5 +361,59 @@ public void CanInstantiateTemplateWithSecondShortName()
.And.NotHaveStdErr()
.And.HaveStdOutContaining("The template \"ASP.NET Core Web App\" was created successfully.");
}

[Fact]
public void CanInstantiateTemplate_WithBinaryFile_FromFolder()
{
string workingDirectory = TestUtils.CreateTemporaryFolder();
string home = TestUtils.CreateTemporaryFolder("Home");
string templateLocation = TestUtils.GetTestTemplateLocation("TemplateWithBinaryFile");

Helpers.InstallTestTemplate(templateLocation, _log, workingDirectory, home);

new DotnetNewCommand(_log, "TestAssets.TemplateWithBinaryFile")
.WithCustomHive(home)
.WithWorkingDirectory(workingDirectory)
.Execute()
.Should().Pass();

string sourceImage = Path.Combine(templateLocation, "image.png");
string targetImage = Path.Combine(workingDirectory, "image.png");

Assert.True(File.Exists(targetImage));

Assert.Equal(
new FileInfo(sourceImage).Length,
new FileInfo(targetImage).Length);
Assert.True(TestUtils.CompareFiles(sourceImage, targetImage), $"The content of {sourceImage} and {targetImage} is not same.");
}

[Fact]
public void CanInstantiateTemplate_WithBinaryFile_FromPackage()
{
string templateLocation = TestUtils.GetTestTemplateLocation("TemplateWithBinaryFile");
string workingDirectory = TestUtils.CreateTemporaryFolder();
string home = TestUtils.CreateTemporaryFolder("Home");

using var packageManager = new PackageManager();
string packageLocation = packageManager.PackTestTemplatesNuGetPackage();
Helpers.InstallNuGetTemplate(packageLocation, _log, workingDirectory, home);

new DotnetNewCommand(_log, "TestAssets.TemplateWithBinaryFile")
.WithCustomHive(home)
.WithWorkingDirectory(workingDirectory)
.Execute()
.Should().Pass();

string sourceImage = Path.Combine(templateLocation, "image.png");
string targetImage = Path.Combine(workingDirectory, "image.png");

Assert.True(File.Exists(targetImage));

Assert.Equal(
new FileInfo(sourceImage).Length,
new FileInfo(targetImage).Length);
Assert.True(TestUtils.CompareFiles(sourceImage, targetImage), $"The content of {sourceImage} and {targetImage} is not same.");
}
}
}

0 comments on commit 25c4f57

Please sign in to comment.