From 07a63d2dddb65e574c5646ccbc38de0a6d1f5805 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 11 Jan 2018 19:48:28 -0800 Subject: [PATCH] Add tests for RazorCompile target This target should be callable on its own without using Build so it deserves a few tests. --- .../RazorCompileIntegrationTest.cs | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs diff --git a/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs new file mode 100644 index 0000000000..513fc18bb9 --- /dev/null +++ b/test/Microsoft.AspNetCore.Razor.Design.Test/IntegrationTests/RazorCompileIntegrationTest.cs @@ -0,0 +1,44 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests +{ + public class RazorCompileIntegrationTest : MSBuildIntegrationTestBase + { + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task RazorCompile_Success_CompilesAssembly() + { + var result = await DotnetMSBuild("RazorCompile"); + + Assert.BuildPassed(result); + + // RazorGenerate should compile the assembly and pdb. + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.pdb"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.PrecompiledViews.dll"); + Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.PrecompiledViews.pdb"); + } + + [Fact] + [InitializeTestProject("SimpleMvc")] + public async Task RazorCompile_NoopsWithNoFiles() + { + Directory.Delete(Path.Combine(Project.DirectoryPath, "Views"), recursive: true); + + var result = await DotnetMSBuild("RazorCompile"); + + Assert.BuildPassed(result); + + // Everything we do should noop - including building the app. + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.dll"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.pdb"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.PrecompiledViews.dll"); + Assert.FileDoesNotExist(result, IntermediateOutputPath, "SimpleMvc.PrecompiledViews.pdb"); + } + } +}