public async Task PublishingPrintsParseErrors() { // Arrange var applicationPath = ApplicationPaths.GetTestAppDirectory("ApplicationWithParseErrors"); var indexPath = Path.Combine(applicationPath, "Views", "Home", "Index.cshtml"); var viewImportsPath = Path.Combine(applicationPath, "Views", "Home", "About.cshtml"); var expectedErrors = new[] { indexPath + " (0): The code block is missing a closing \"}\" character. Make sure you have a matching \"}\" character for all the \"{\" characters within this block, and that none of the \"}\" characters are being interpreted as markup.", viewImportsPath + " (1): A space or line break was encountered after the \"@\" character. Only valid identifiers, keywords, comments, \"(\" and \"{\" are valid at the start of a code block and they must occur immediately following \"@\" with no space in between.", }; var testSink = new TestSink(); var loggerFactory = new TestLoggerFactory(testSink, enabled: true); // Act await Assert.ThrowsAsync <Exception>(() => Fixture.CreateDeploymentAsync(loggerFactory)); // Assert var logs = testSink.Writes.Select(w => w.State.ToString().Trim()).ToList(); foreach (var expectedError in expectedErrors) { Assert.Contains(logs, log => log.Contains(expectedError)); } }
protected ApplicationTestFixture(string applicationName, string applicationPath) { ApplicationName = applicationName; ApplicationPath = applicationPath ?? ApplicationPaths.GetTestAppDirectory(applicationName); WorkingDirectory = Path.Combine(Path.GetTempPath(), "PrecompilationTool", Path.GetRandomFileName()); TestProjectDirectory = Path.Combine(WorkingDirectory, ApplicationName); }
public void CrossPublishingWorks() { using (StartLog(out var loggerFactory)) { // Arrange var applicationName = nameof(SimpleApp); var applicationPath = ApplicationPaths.GetTestAppDirectory(applicationName); var deploymentParameters = ApplicationTestFixture.GetDeploymentParameters( applicationPath, applicationName, RuntimeFlavor.CoreClr); // Deploy for a rid that does not exist on the current platform. if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { deploymentParameters.AdditionalPublishParameters = "-r debian-x64"; } else { deploymentParameters.AdditionalPublishParameters = "-r win7-x86"; } var deployer = new DotNetPublishDeployer(deploymentParameters, loggerFactory); // Act deployer.DotnetPublish(); // Act var expectedFile = Path.Combine( deploymentParameters.PublishedApplicationRootPath, $"{applicationName}.PrecompiledViews.dll"); Assert.True(File.Exists(expectedFile), $"Expected precompiled file {expectedFile} does not exist."); } }
protected ApplicationTestFixture(string applicationName, string applicationPath) { ApplicationName = applicationName; ApplicationPath = applicationPath ?? ApplicationPaths.GetTestAppDirectory(applicationName); }
public TestFixture() : base( typeof(SimpleAppWithAssemblyRename.Startup).Assembly.GetName().Name, ApplicationPaths.GetTestAppDirectory(nameof(SimpleAppWithAssemblyRename))) { }