void RunScriptInternal(RunScriptParams message) { var blockingCollection = ConsoleHostServices.ActiveBlockingCollection; var version = NuGet.Versioning.NuGetVersion.Parse(message.PackageVersion); var identity = new PackageIdentity(message.PackageId, version); var project = ProjectFactory.CreateProject(message.Project); var scriptMessage = new ScriptMessage( message.ScriptPath, message.InstallPath, identity, project); blockingCollection.Add(scriptMessage); WaitHandle.WaitAny(new WaitHandle[] { scriptMessage.EndSemaphore, cancellationTokenSource.Token.WaitHandle }); if (scriptMessage.Exception == null) { return; } if (message.ThrowOnFailure) { throw scriptMessage.Exception; } Log(LogLevel.Warning, scriptMessage.Exception.Message); }
public async Task WorkerTemplateAsync(string language, string[] args) { var project = await ProjectFactory.CreateProject(Output); var createResult = await project.RunDotNetNewAsync("worker", language : language, args : args); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult)); var publishResult = await project.RunDotNetPublishAsync(); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult)); // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build // later, while the opposite is not true. var buildResult = await project.RunDotNetBuildAsync(); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult)); using (var aspNetProcess = project.StartBuiltProjectAsync(hasListeningUri: false)) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); } using (var aspNetProcess = project.StartPublishedProjectAsync(hasListeningUri: false)) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", project, aspNetProcess.Process)); } }
public async Task IdentityUIPackage_WorksWithDifferentOptions() { var packageOptions = new Dictionary <string, string>(); var project = await ProjectFactory.CreateProject(Output); var useLocalDB = false; var createResult = await project.RunDotNetNewAsync("razor", auth : "Individual", useLocalDB : useLocalDB, environmentVariables : packageOptions); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult)); var projectFileContents = ReadFile(project.TemplateOutputDir, $"{project.ProjectName}.csproj"); Assert.Contains(".db", projectFileContents); var publishResult = await project.RunDotNetPublishAsync(packageOptions : packageOptions); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult)); // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build // later, while the opposite is not true. var buildResult = await project.RunDotNetBuildAsync(packageOptions : packageOptions); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult)); var migrationsResult = await project.RunDotNetEfCreateMigrationAsync("razorpages"); Assert.True(0 == migrationsResult.ExitCode, ErrorMessages.GetFailedProcessMessage("run EF migrations", project, migrationsResult)); project.AssertEmptyMigration("razorpages"); var versionValidator = "Bootstrap v5.1.0"; using (var aspNetProcess = project.StartBuiltProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); var response = await aspNetProcess.SendRequest("/Identity/lib/bootstrap/dist/css/bootstrap.css"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Contains(versionValidator, await response.Content.ReadAsStringAsync()); await ValidatePublishedFiles(aspNetProcess, Bootstrap5ContentFiles); } using (var aspNetProcess = project.StartPublishedProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); var response = await aspNetProcess.SendRequest("/Identity/lib/bootstrap/dist/css/bootstrap.css"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Contains(versionValidator, await response.Content.ReadAsStringAsync()); await ValidatePublishedFiles(aspNetProcess, Bootstrap5ContentFiles); } }
public void AProjectWithoutWorkingCalendarIsCreatedWithDefaultWorkingCalendar() { DateTime monday = new DateTime(2013, 7, 1); DateTime tuesday = new DateTime(2013, 7, 2); DateTime wednesday = new DateTime(2013, 7, 3); DateTime thursday = new DateTime(2013, 7, 4); DateTime friday = new DateTime(2013, 7, 5); DateTime saturday = new DateTime(2013, 7, 6); DateTime sunday = new DateTime(2013, 7, 7); ProjectFactory projectFactory = new ProjectFactory(calendarFactory); Project project = projectFactory.CreateProject(VALID_PROJECT_NAME); IProjectCalendar calendar = project.Calendar; Assert.That(calendar.IsWorkingDay(monday), Is.True); Assert.That(calendar.IsWorkingDay(tuesday), Is.True); Assert.That(calendar.IsWorkingDay(wednesday), Is.True); Assert.That(calendar.IsWorkingDay(thursday), Is.True); Assert.That(calendar.IsWorkingDay(friday), Is.True); Assert.That(calendar.IsWorkingDay(saturday), Is.False); Assert.That(calendar.IsWorkingDay(sunday), Is.False); Assert.That(calendar.GetWorkingHours(monday), Is.EqualTo(8)); Assert.That(calendar.GetWorkingHours(tuesday), Is.EqualTo(8)); Assert.That(calendar.GetWorkingHours(wednesday), Is.EqualTo(8)); Assert.That(calendar.GetWorkingHours(thursday), Is.EqualTo(8)); Assert.That(calendar.GetWorkingHours(friday), Is.EqualTo(8)); Assert.That(calendar.GetWorkingHours(saturday), Is.EqualTo(0)); Assert.That(calendar.GetWorkingHours(sunday), Is.EqualTo(0)); }
public void AProjectWhichLastFromMondayToThursdayAnd6WorkingHoursPerDayAndHasWednesdayHolidayHas18WorkingHoursExpectedEffort() { DateTime today = DateTime.Today; DateTime monday = CalulateNext(today, DayOfWeek.Monday); DateTime tuesday = CalulateNext(monday, DayOfWeek.Tuesday); DateTime wednesday = CalulateNext(monday, DayOfWeek.Wednesday); DateTime thursday = CalulateNext(monday, DayOfWeek.Thursday); Mock <IProjectCalendar> calendarMock = new Mock <IProjectCalendar>(); calendarMock.Setup(x => x.GetWorkingHours(monday)).Returns(6); calendarMock.Setup(x => x.GetWorkingHours(tuesday)).Returns(6); calendarMock.Setup(x => x.GetWorkingHours(wednesday)).Returns(0); calendarMock.Setup(x => x.GetWorkingHours(thursday)).Returns(6); ProjectFactory projectFactory = new ProjectFactory(null); Project project = projectFactory.CreateProject(calendarMock.Object, VALID_PROJECT_NAME); project.ExpectedStartDate = monday; project.ExpectedFinishDate = thursday; float effort = project.CalculateExpectedEffort(); Assert.That(effort, Is.EqualTo(18f)); }
public void ATaskWithoutChildTaskHasItsOwnExpectedEffort() { DateTime today = DateTime.Today; DateTime monday = CalulateNext(today, DayOfWeek.Monday); DateTime tuesday = CalulateNext(monday, DayOfWeek.Tuesday); DateTime wednesday = CalulateNext(monday, DayOfWeek.Wednesday); DateTime thursday = CalulateNext(monday, DayOfWeek.Thursday); DateTime friday = CalulateNext(monday, DayOfWeek.Friday); Mock <IProjectCalendar> calendarMock = new Mock <IProjectCalendar>(); calendarMock.Setup(x => x.GetWorkingHours(monday)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(tuesday)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(wednesday)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(thursday)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(friday)).Returns(8); Mock <IProjectCalendarFactory> calendarFactoryMock = new Mock <IProjectCalendarFactory>(); calendarFactoryMock.Setup(x => x.CreateDefaultWorkingCalendar()).Returns(calendarMock.Object); ProjectFactory projectFactory = new ProjectFactory(calendarFactoryMock.Object); Project project = projectFactory.CreateProject(VALID_PROJECT_NAME); ProjectTask task = project.AddTask(VALID_PROJECTTASK_NAME); task.ExpectedStartDate = monday; task.ExpectedFinishDate = friday; float effort = task.CalculateExpectedEffort(); Assert.That(effort, Is.EqualTo(40f)); }
public void CannotCreateAProjectWithoutAWorkingCalendar() { ProjectFactory projectFactory = new ProjectFactory(calendarFactory); Exception caughtException = Assert.Catch(() => projectFactory.CreateProject(null, VALID_PROJECT_NAME)); Assert.That(caughtException, Is.InstanceOf <InvalidActivityCalendarException>()); }
public void AProjectHasName() { ProjectFactory projectFactory = new ProjectFactory(calendarFactory); Project project = projectFactory.CreateProject(VALID_PROJECT_NAME); string projectName = project.Name; Assert.That(projectName, Is.EqualTo(VALID_PROJECT_NAME)); }
public void CannotCreateAProjectWithEmptyName() { ProjectFactory projectFactory = new ProjectFactory(calendarFactory); ProjectCalendarFactory workingCalendarFactory = new ProjectCalendarFactory(); IProjectCalendar calendar = workingCalendarFactory.CreateDefaultWorkingCalendar(); Exception caughtException = Assert.Catch(() => projectFactory.CreateProject(calendar, "")); Assert.That(caughtException, Is.InstanceOf <InvalidActivityNameException>()); }
public async Task BlazorServerItemTemplate() { Project = await ProjectFactory.CreateProject(Output); var createResult = await Project.RunDotNetNewAsync("razorcomponent --name Different"); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create", Project, createResult)); Project.AssertFileExists("Different.razor", shouldExist: true); Assert.Contains("<h3>Different</h3>", Project.ReadFile("Different.razor")); }
public HttpResponseMessage ValidateProject(int projectId, int connectionId = 0) { try { var project = _projectFactory.CreateProject(projectId); Connection connection; if (connectionId == 0) { connection = _dataRepository.ConnectionRepository .GetDataByProjectId(projectId) .FirstOrDefault(x => x.IsActive & x.IsDefault & x.ProjectId == projectId); if (connection != null) { connection.ConnectionProvider = _dataRepository.ConnectionProviderRepository.GetDataById(connection.ConnectionProviderId) .FirstOrDefault(); connectionId = connection.ConnectionId; } } else { connection = _connectionFactory.CreateConnection(connectionId); } var validationProject = new ValidationProject(_dataRepository, projectId); if (!validationProject.ValidateConnection(connectionId)) { throw new Exception(ConnectionNotValid); } foreach (var test in project.Tests) { validationProject.ValidationTests.Add(new ValidationTest(connection, test)); } foreach (var testGroup in project.TestGroups) { validationProject.ValidationTestGroups.Add(new ValidationTestGroup(connection, testGroup)); } var valCollection = validationProject.Validate(); PersistValidationResults(valCollection, null, projectId); return(Request.CreateResponse(HttpStatusCode.OK, validationProject)); } catch (Exception ex) { return (Request.CreateErrorResponse( ex.Message == ConnectionNotValid ? HttpStatusCode.BadRequest : HttpStatusCode.InternalServerError, new HttpError(ex.Message))); } }
public async Task Template_Produces_The_Right_Set_Of_FilesAsync(string arguments, string[] expectedFiles) { Project = await ProjectFactory.CreateProject(Output); var createResult = await Project.RunDotNetNewRawAsync(arguments); Assert.True(createResult.ExitCode == 0, createResult.GetFormattedOutput()); foreach (var file in expectedFiles) { AssertFileExists(Project.TemplateOutputDir, file, shouldExist: true); } var filesInFolder = Directory.EnumerateFiles(Project.TemplateOutputDir, "*", SearchOption.AllDirectories); foreach (var file in filesInFolder) { var relativePath = file.Replace(Project.TemplateOutputDir, "").Replace("\\", "/").Trim('/'); if (relativePath.EndsWith(".csproj", StringComparison.Ordinal) || relativePath.EndsWith(".fsproj", StringComparison.Ordinal) || relativePath.EndsWith(".props", StringComparison.Ordinal) || relativePath.EndsWith(".targets", StringComparison.Ordinal) || relativePath.StartsWith("bin/", StringComparison.Ordinal) || relativePath.StartsWith("obj/", StringComparison.Ordinal) || relativePath.EndsWith(".sln", StringComparison.Ordinal) || relativePath.EndsWith(".targets", StringComparison.Ordinal) || relativePath.StartsWith("bin/", StringComparison.Ordinal) || relativePath.StartsWith("obj/", StringComparison.Ordinal) || relativePath.Contains("/bin/", StringComparison.Ordinal) || relativePath.Contains("/obj/", StringComparison.Ordinal)) { continue; } Assert.Contains(relativePath, expectedFiles); if (relativePath.EndsWith(".cs", StringComparison.Ordinal)) { var namespaceDeclarationPrefix = "namespace "; var namespaceDeclaration = File.ReadLines(file) .SingleOrDefault(line => line.StartsWith(namespaceDeclarationPrefix, StringComparison.Ordinal)) ?.Substring(namespaceDeclarationPrefix.Length); // nullable because Program.cs with top-level statements doesn't have a namespace declaration if (namespaceDeclaration is not null) { Assert.StartsWith(Project.ProjectName, namespaceDeclaration, StringComparison.Ordinal); } } } }
private async Task EmtpyTemplateCore(string languageOverride, string[] args = null) { var project = await ProjectFactory.CreateProject(Output); var createResult = await project.RunDotNetNewAsync("web", args : args, language : languageOverride); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult)); var noHttps = args?.Contains(ArgConstants.NoHttps) ?? false; var expectedLaunchProfileNames = noHttps ? new[] { "http", "IIS Express" } : new[] { "http", "https", "IIS Express" }; await project.VerifyLaunchSettings(expectedLaunchProfileNames); // Avoid the F# compiler. See https://github.com/dotnet/aspnetcore/issues/14022 if (languageOverride != null) { return; } var publishResult = await project.RunDotNetPublishAsync(); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult)); // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build // later, while the opposite is not true. var buildResult = await project.RunDotNetBuildAsync(); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult)); using (var aspNetProcess = project.StartBuiltProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); await aspNetProcess.AssertOk("/"); } using (var aspNetProcess = project.StartPublishedProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", project, aspNetProcess.Process)); await aspNetProcess.AssertOk("/"); } }
public void ATaskWithChildrenTasksHasProgressBasedOnItsChildren() { DateTime today = DateTime.Today; DateTime monday = CalulateNext(today, DayOfWeek.Monday); DateTime tuesday = CalulateNext(monday, DayOfWeek.Tuesday); DateTime wednesday = CalulateNext(monday, DayOfWeek.Wednesday); DateTime thursday = CalulateNext(monday, DayOfWeek.Thursday); DateTime friday = CalulateNext(monday, DayOfWeek.Friday); Mock <IProjectCalendar> calendarMock = new Mock <IProjectCalendar>(); calendarMock.Setup(x => x.GetWorkingHours(monday)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(tuesday)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(wednesday)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(thursday)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(friday)).Returns(8); Mock <IProjectCalendarFactory> calendarFactoryMock = new Mock <IProjectCalendarFactory>(); calendarFactoryMock.Setup(x => x.CreateDefaultWorkingCalendar()).Returns(calendarMock.Object); ProjectFactory projectFactory = new ProjectFactory(calendarFactoryMock.Object); Project project = projectFactory.CreateProject(VALID_PROJECT_NAME); ProjectTask parentTask = project.AddTask(VALID_PROJECTTASK_NAME); ProjectTask childTask1 = parentTask.AddTask(VALID_PROJECTTASK_NAME); ProjectTask childTask2 = parentTask.AddTask(VALID_PROJECTTASK_NAME); ProjectTask childTask3 = parentTask.AddTask(VALID_PROJECTTASK_NAME); // 40 hours effort, 10% progress childTask1.ExpectedStartDate = monday; childTask1.ExpectedFinishDate = friday; childTask1.SetProgress(10); // 40 hours effort, 25% progress childTask2.ExpectedStartDate = monday; childTask2.ExpectedFinishDate = friday; childTask2.SetProgress(25); // 24 hours effort, 50% progress childTask3.ExpectedStartDate = monday; childTask3.ExpectedFinishDate = wednesday; childTask3.SetProgress(50); int progress = parentTask.CalculateProgress(); Assert.That(progress, Is.EqualTo(25)); }
public async Task MvcTemplate_SingleFileExe() { // This test verifies publishing an MVC app as a single file exe works. We'll limit testing // this to a few operating systems to make our lives easier. var runtimeIdentifer = "win-x64"; var project = await ProjectFactory.CreateProject(Output); project.RuntimeIdentifier = runtimeIdentifer; var createResult = await project.RunDotNetNewAsync("mvc"); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult)); var publishResult = await project.RunDotNetPublishAsync(additionalArgs : $"/p:PublishSingleFile=true -r {runtimeIdentifer} --self-contained", noRestore : false); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult)); var menuLinks = new[] { PageUrls.HomeUrl, PageUrls.HomeUrl, PageUrls.PrivacyFullUrl }; var footerLinks = new[] { PageUrls.PrivacyFullUrl }; var pages = new List <Page> { new Page { Url = PageUrls.HomeUrl, Links = menuLinks.Append(PageUrls.DocsUrl).Concat(footerLinks), }, new Page { Url = PageUrls.PrivacyFullUrl, Links = menuLinks.Concat(footerLinks), } }; using var aspNetProcess = project.StartPublishedProjectAsync(usePublishedAppHost: true); Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", project, aspNetProcess.Process)); await aspNetProcess.AssertPagesOk(pages); }
protected async Task <Project> CreateBuildPublishAsync(string auth = null, string[] args = null, string targetFramework = null, bool serverProject = false, bool onlyCreate = false) { // Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278 Environment.SetEnvironmentVariable("EnableDefaultScopedCssItems", "true"); var project = await ProjectFactory.CreateProject(Output); if (targetFramework != null) { project.TargetFramework = targetFramework; } var createResult = await project.RunDotNetNewAsync(ProjectType, auth : auth, args : args, errorOnRestoreError : false); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult)); if (serverProject || auth is null) { // External auth mechanisms (which is any auth at all for Blazor WASM) require https to work and thus don't honor the --no-https flag var requiresHttps = string.Equals(auth, "IndividualB2C", StringComparison.OrdinalIgnoreCase) || string.Equals(auth, "SingleOrg", StringComparison.OrdinalIgnoreCase) || (!serverProject && auth is not null); var noHttps = args?.Contains(ArgConstants.NoHttps) ?? false; var expectedLaunchProfileNames = requiresHttps ? new[] { "https", "IIS Express" } : noHttps ? new[] { "http", "IIS Express" } : new[] { "http", "https", "IIS Express" }; await project.VerifyLaunchSettings(expectedLaunchProfileNames); } if (!onlyCreate) { var targetProject = project; if (serverProject) { targetProject = GetSubProject(project, "Server", $"{project.ProjectName}.Server"); } var publishResult = await targetProject.RunDotNetPublishAsync(noRestore : false); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", targetProject, publishResult)); } return(project); }
public async Task RazorClassLibraryTemplateAsync() { var project = await ProjectFactory.CreateProject(Output); var createResult = await project.RunDotNetNewAsync("razorclasslib"); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult)); var publishResult = await project.RunDotNetPublishAsync(); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult)); // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build // later, while the opposite is not true. var buildResult = await project.RunDotNetBuildAsync(); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult)); }
private bool CreateProjectFromPackage() { PackageContext packageContext = null; List <InputResult> inputResults = new List <InputResult>(); Project project = null; if (locationTextBox.Text.IsNullOrEmpty() || !Directory.Exists(locationTextBox.Text)) { MessageBox.Show("Please enter or select a valid location to create your project.", null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } progressLabel.Text = "Initializing"; progressBar.Value = 0; progressPanel.Visible = true; //Extract package inputs. inputResults = packageInputsFlowPanel.Controls.OfType <PackageInput>().Select(c => c.GetInputResult()).ToList(); //Create the project. packageContext = new PackageContext(_selectedPackage, locationTextBox.Text, inputResults); try { ProjectFactory projectFactory = new ProjectFactory(); projectFactory.ReportProgress += new Common.ReportProgressEventHandler(projectFactory_ReportProgress); project = projectFactory.CreateProject(packageContext); projectFactory.ReportProgress -= new Common.ReportProgressEventHandler(projectFactory_ReportProgress); } catch (Exception ex) { MessageBox.Show(ex.Message); progressPanel.Visible = false; return(false); } ProjectContext.Initialize(project); return(true); }
public void AProjectWhichLastFromMondayToFridayOfNextWeekAnd8WorkingHoursPerDayHas80WorkingHoursExpectedEffort() { DateTime today = DateTime.Today; DateTime mondayWeek1 = CalulateNext(today, DayOfWeek.Monday); DateTime tuesdayWeek1 = CalulateNext(mondayWeek1, DayOfWeek.Tuesday); DateTime wednesdayWeek1 = CalulateNext(mondayWeek1, DayOfWeek.Wednesday); DateTime thursdayWeek1 = CalulateNext(mondayWeek1, DayOfWeek.Thursday); DateTime fridayWeek1 = CalulateNext(mondayWeek1, DayOfWeek.Friday); DateTime saturdayWeek1 = CalulateNext(mondayWeek1, DayOfWeek.Saturday); DateTime sundayWeek1 = CalulateNext(mondayWeek1, DayOfWeek.Sunday); DateTime mondayWeek2 = mondayWeek1.AddDays(7); DateTime tuesdayWeek2 = CalulateNext(mondayWeek2, DayOfWeek.Tuesday); DateTime wednesdayWeek2 = CalulateNext(mondayWeek2, DayOfWeek.Wednesday); DateTime thursdayWeek2 = CalulateNext(mondayWeek2, DayOfWeek.Thursday); DateTime fridayWeek2 = CalulateNext(mondayWeek2, DayOfWeek.Friday); Mock <IProjectCalendar> calendarMock = new Mock <IProjectCalendar>(); calendarMock.Setup(x => x.GetWorkingHours(mondayWeek1)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(tuesdayWeek1)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(wednesdayWeek1)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(thursdayWeek1)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(fridayWeek1)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(saturdayWeek1)).Returns(0); calendarMock.Setup(x => x.GetWorkingHours(sundayWeek1)).Returns(0); calendarMock.Setup(x => x.GetWorkingHours(mondayWeek2)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(tuesdayWeek2)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(wednesdayWeek2)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(thursdayWeek2)).Returns(8); calendarMock.Setup(x => x.GetWorkingHours(fridayWeek2)).Returns(8); ProjectFactory projectFactory = new ProjectFactory(null); Project project = projectFactory.CreateProject(calendarMock.Object, VALID_PROJECT_NAME); project.ExpectedStartDate = mondayWeek1; project.ExpectedFinishDate = fridayWeek2; float effort = project.CalculateExpectedEffort(); Assert.That(effort, Is.EqualTo(80f)); }
public async Task SpaTemplates_BuildAndPublish(string template, string auth) { var project = await ProjectFactory.CreateProject(Output); var args = new[] { "--NoSpaFrontEnd", "true" }; var createResult = await project.RunDotNetNewAsync(template, auth : auth, args : args); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage(template, project, createResult)); var publishResult = await project.RunDotNetPublishAsync(); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult)); // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build // later, while the opposite is not true. var buildResult = await project.RunDotNetBuildAsync(); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult)); }
public void ATaskWithAChildTasksHasProgressBasedOnItsChild() { DateTime today = DateTime.Today; DateTime monday = CalulateNext(today, DayOfWeek.Monday); Mock <IProjectCalendar> calendarMock = new Mock <IProjectCalendar>(); calendarMock.Setup(x => x.GetWorkingHours(monday)).Returns(8); ProjectFactory projectFactory = new ProjectFactory(null); Project project = projectFactory.CreateProject(calendarMock.Object, VALID_PROJECT_NAME); ProjectTask task = AddProjectTask(project); task.ExpectedStartDate = monday; task.ExpectedFinishDate = monday; task.SetProgress(22); int progress = project.CalculateProgress(); Assert.That(progress, Is.EqualTo(22)); }
protected async Task <Project> CreateBuildPublishAsync(string auth = null, string[] args = null, string targetFramework = null, bool serverProject = false, bool onlyCreate = false) { // Additional arguments are needed. See: https://github.com/dotnet/aspnetcore/issues/24278 Environment.SetEnvironmentVariable("EnableDefaultScopedCssItems", "true"); var project = await ProjectFactory.CreateProject(Output); if (targetFramework != null) { project.TargetFramework = targetFramework; } var createResult = await project.RunDotNetNewAsync(ProjectType, auth : auth, args : args); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult)); if (!onlyCreate) { var targetProject = project; if (serverProject) { targetProject = GetSubProject(project, "Server", $"{project.ProjectName}.Server"); } var publishResult = await targetProject.RunDotNetPublishAsync(noRestore : false); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", targetProject, publishResult)); // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build // later, while the opposite is not true. var buildResult = await targetProject.RunDotNetBuildAsync(); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", targetProject, buildResult)); } return(project); }
private async Task <Project> BuildAndPublishRazorPagesTemplateIdentityWeb(string auth, string[] args) { var project = await ProjectFactory.CreateProject(Output); var createResult = await project.RunDotNetNewAsync("razor", auth : auth, args : args); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult)); // Identity Web auth requires https and thus ignores the --no-https option if passed so there should never be an 'http' profile var expectedLaunchProfileNames = new[] { "https", "IIS Express" }; await project.VerifyLaunchSettings(expectedLaunchProfileNames); // Verify building in debug works var buildResult = await project.RunDotNetBuildAsync(); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult)); // Publish builds in "release" configuration. Running publish should ensure we can compile in release and that we can publish without issues. buildResult = await project.RunDotNetPublishAsync(); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, buildResult)); return(project); }
private static void PopulatingDb() { var personsList = new List <Person>(); var companylist = new List <Company>(); var salary = new Salary(1500, 0.0); var salary2 = new Salary(1600, 0.0); var salary3 = new Salary(1700, 0.0); var salary4 = new Salary(1520, 0.0); var salary5 = new Salary(1300, 0.0); var salary6 = new Salary(1540, 0.0); var salary7 = new Salary(1550, 0.0); var salary8 = new Salary(1570, 0.0); var salary9 = new Salary(1680, 0.0); var salary10 = new Salary(1520, 0.0); var newAddress = new Address("Monumentul Stefan cel Mare", "Chisinau"); var newAddress2 = new Address("Aleco Ruso", "Chisinau"); var newAddress3 = new Address("bd Decebal", "Chisinau"); var newAddress4 = new Address("bd Miorita", "Chisinau"); var newAddress5 = new Address("bd Renasterii", "Chisinau"); var newAddress6 = new Address("Monumentul Stefan cel Mare", "Chisinau"); var newAddress7 = new Address("Aleco Ruso", "Chisinau"); var newAddress8 = new Address("bd Decebal", "Chisinau"); var newAddress9 = new Address("bd Miorita", "Chisinau"); var newAddress10 = new Address("bd Renasterii", "Chisinau"); var newAddress11 = new Address("Monumentul Stefan cel Mare", "Chisinau"); var newAddress12 = new Address("Aleco Ruso", "Chisinau"); var newAddress13 = new Address("bd Decebal", "Chisinau"); var newAddress14 = new Address("bd Miorita", "Chisinau"); var newAddress15 = new Address("bd Renasterii", "Chisinau"); var newAddress16 = new Address("Monumentul Stefan cel Mare", "Chisinau"); var newAddress17 = new Address("Aleco Ruso", "Chisinau"); var newAddress18 = new Address("bd Decebal", "Chisinau"); var newAddress19 = new Address("bd Miorita", "Chisinau"); var newAddress20 = new Address("bd Renasterii", "Chisinau"); var skills = new Dictionary <string, int> { { "C#", 80 }, { "SQL", 90 } }; var skills2 = new Dictionary <string, int> { { "CSS", 80 }, { "PHP", 90 }, { "HTML", 90 } }; var skills3 = new Dictionary <string, int> { { "JavaScript", 80 }, { "HTML", 90 } }; var skills4 = new Dictionary <string, int> { { "C++", 80 } }; var skills5 = new Dictionary <string, int> { { "C#", 80 }, { "SQL", 90 }, { "CSS", 80 }, { "PHP", 90 }, { "HTML", 90 } }; var comp = CompanyFactory.CreateCompany("Imea", FieldOfActivity.IT, newAddress); var comp2 = CompanyFactory.CreateCompany("WIKER", FieldOfActivity.IT, newAddress2); var comp3 = CompanyFactory.CreateCompany("Bones", FieldOfActivity.IT, newAddress3); var comp4 = CompanyFactory.CreateCompany("XQT", FieldOfActivity.IT, newAddress4); var comp5 = CompanyFactory.CreateCompany("Akigor", FieldOfActivity.IT, newAddress5); companylist.Add(comp); companylist.Add(comp2); companylist.Add(comp3); companylist.Add(comp4); companylist.Add(comp5); var proj = ProjectFactory.CreateProject(comp, "Nima", "Project nr 1"); var proj2 = ProjectFactory.CreateProject(comp, "BJH", "Project nr 2"); var proj3 = ProjectFactory.CreateProject(comp, "XAF", "Project nr 3"); comp.AddProject(proj); comp.AddProject(proj2); comp.AddProject(proj3); comp5.AddProject(proj2); var proj4 = ProjectFactory.CreateProject(comp2, "P1", "Project nr 1"); var proj5 = ProjectFactory.CreateProject(comp2, "P2", "Project nr 2"); var proj6 = ProjectFactory.CreateProject(comp2, "P3", "Project nr 3"); var proj7 = ProjectFactory.CreateProject(comp2, "P4", "Project nr 4"); var proj8 = ProjectFactory.CreateProject(comp2, "P5", "Project nr 5"); comp2.AddProject(proj4); comp2.AddProject(proj5); comp2.AddProject(proj6); comp2.AddProject(proj7); comp2.AddProject(proj8); comp5.AddProject(proj7); var proj9 = ProjectFactory.CreateProject(comp3, "1Pr", "Project nr 1"); var proj10 = ProjectFactory.CreateProject(comp3, "2Pr", "Project nr 2"); var proj11 = ProjectFactory.CreateProject(comp3, "3Pr", "Project nr 3"); var proj12 = ProjectFactory.CreateProject(comp3, "4Pr", "Project nr 4"); var proj13 = ProjectFactory.CreateProject(comp3, "5Pr", "Project nr 5"); var proj14 = ProjectFactory.CreateProject(comp3, "6Pr", "Project nr 6"); comp3.AddProject(proj9); comp3.AddProject(proj10); comp3.AddProject(proj11); comp3.AddProject(proj12); comp3.AddProject(proj13); comp3.AddProject(proj14); comp5.AddProject(proj11); var task1 = TaskFactory.CreateTask(proj, "Task1", "Description", "12.12.2016"); var task2 = TaskFactory.CreateTask(proj2, "Task1", "Description", "12.12.2016"); var task3 = TaskFactory.CreateTask(proj3, "Task1", "Description", "12.12.2016"); var task4 = TaskFactory.CreateTask(proj4, "Task1", "Description", "12.12.2016"); var task5 = TaskFactory.CreateTask(proj5, "Task1", "Description", "12.12.2016"); var task6 = TaskFactory.CreateTask(proj6, "Task1", "Description", "12.12.2016"); var task7 = TaskFactory.CreateTask(proj7, "Task1", "Description", "12.12.2016"); var task8 = TaskFactory.CreateTask(proj8, "Task1", "Description", "12.12.2016"); var task9 = TaskFactory.CreateTask(proj9, "Task1", "Description", "12.12.2016"); var task10 = TaskFactory.CreateTask(proj10, "Task1", "Description", "12.12.2016"); var task11 = TaskFactory.CreateTask(proj11, "Task1", "Description", "12.12.2016"); var task12 = TaskFactory.CreateTask(proj12, "Task1", "Description", "12.12.2016"); var task13 = TaskFactory.CreateTask(proj13, "Task1", "Description", "12.12.2016"); var task14 = TaskFactory.CreateTask(proj14, "Task1", "Description", "12.12.2016"); var task15 = TaskFactory.CreateTask(proj, "Task2", "Description", "12.12.2016"); var task16 = TaskFactory.CreateTask(proj2, "Task2", "Description", "12.12.2016"); var task17 = TaskFactory.CreateTask(proj3, "Task2", "Description", "12.12.2016"); var task18 = TaskFactory.CreateTask(proj4, "Task2", "Description", "12.12.2016"); var task19 = TaskFactory.CreateTask(proj, "Task3", "Description", "12.12.2016"); var task20 = TaskFactory.CreateTask(proj2, "Task3", "Description", "12.12.2016"); proj.AddTask(task1); proj.AddTask(task15); proj.AddTask(task19); proj2.AddTask(task2); proj2.AddTask(task16); proj2.AddTask(task20); proj3.AddTask(task3); proj3.AddTask(task17); proj4.AddTask(task4); proj4.AddTask(task18); proj5.AddTask(task5); proj6.AddTask(task6); proj7.AddTask(task7); proj8.AddTask(task8); proj9.AddTask(task9); proj10.AddTask(task10); proj11.AddTask(task11); proj12.AddTask(task12); proj13.AddTask(task13); proj14.AddTask(task14); var intern = InternFactory.CreateIntern("Vasile", "Ion", DateTime.Parse("1990-12-13"), skills, newAddress6, comp, 80); var intern2 = InternFactory.CreateIntern("Artur", "Rusnac", DateTime.Parse("1990-12-13"), skills2, newAddress7, comp2, 80); var intern3 = InternFactory.CreateIntern("Alex", "Maioco", DateTime.Parse("1990-12-13"), skills3, newAddress8, comp3, 80); var intern4 = InternFactory.CreateIntern("Max", "Josan", DateTime.Parse("1990-12-13"), skills4, newAddress9, comp4, 80); var intern5 = InternFactory.CreateIntern("Rumulus", "Remus", DateTime.Parse("1990-12-13"), skills5, newAddress10, comp5, 80); personsList.Add(intern); personsList.Add(intern2); personsList.Add(intern3); personsList.Add(intern4); personsList.Add(intern5); var contr1 = ContractorFactory.CreateContractor("Iulius", "Cezar", DateTime.Parse("1980-05-01"), skills3, newAddress11, comp, 11, salary); var contr2 = ContractorFactory.CreateContractor("Junior", "Vamp", DateTime.Parse("1980-05-01"), skills2, newAddress12, comp2, 12, salary2); var contr3 = ContractorFactory.CreateContractor("Hugo", "Boss", DateTime.Parse("1980-05-01"), skills, newAddress13, comp3, 13, salary3); var contr4 = ContractorFactory.CreateContractor("Jason", "Statham", DateTime.Parse("1980-05-01"), skills4, newAddress14, comp4, 14, salary4); var contr5 = ContractorFactory.CreateContractor("Guy", "Rich", DateTime.Parse("1980-05-01"), skills3, newAddress15, comp2, 15, salary5); personsList.Add(contr1); personsList.Add(contr2); personsList.Add(contr3); personsList.Add(contr4); personsList.Add(contr5); var emp = EmployeeFactory.CreateEmployee("John", "Doe", DateTime.Parse("1980-04-01"), skills2, newAddress16, comp, 20, salary6, "Test", "Testing Ingineer"); var emp2 = EmployeeFactory.CreateEmployee("Jim", "Dole", DateTime.Parse("1990-05-10"), skills, newAddress17, comp2, 30, salary7, "Softwer Development", "Software developer"); var emp3 = EmployeeFactory.CreateEmployee("Anne", "Fireman", DateTime.Parse("1995-12-12"), skills3, newAddress18, comp3, 60, salary8, "Test", "Testing Ingineer"); var emp4 = EmployeeFactory.CreateEmployee("Vanessa", "Ginger", DateTime.Parse("1996-11-01"), skills4, newAddress19, comp4, 70, salary9, "Softwer Development", "Software developer"); var emp5 = EmployeeFactory.CreateEmployee("Will", "Smith", DateTime.Parse("1990-11-01"), skills4, newAddress20, comp4, 70, salary10, "Softwer Development", "Software developer"); personsList.Add(emp); personsList.Add(emp2); personsList.Add(emp3); personsList.Add(emp4); personsList.Add(emp5); CompanyRepository.AddCompany(companylist[0]); CompanyRepository.AddCompany(companylist[1]); CompanyRepository.AddCompany(companylist[2]); CompanyRepository.AddCompany(companylist[3]); CompanyRepository.AddCompany(companylist[4]); PersonRepository.AddPerson(personsList[0]); PersonRepository.AddPerson(personsList[1]); PersonRepository.AddPerson(personsList[2]); PersonRepository.AddPerson(personsList[3]); PersonRepository.AddPerson(personsList[4]); PersonRepository.AddPerson(personsList[5]); PersonRepository.AddPerson(personsList[6]); PersonRepository.AddPerson(personsList[7]); PersonRepository.AddPerson(personsList[8]); PersonRepository.AddPerson(personsList[9]); PersonRepository.AddPerson(personsList[10]); PersonRepository.AddPerson(personsList[11]); PersonRepository.AddPerson(personsList[12]); PersonRepository.AddPerson(personsList[13]); PersonRepository.AddPerson(personsList[14]); PersonRepository.AddPerson(personsList[15]); }
public async Task RazorPagesTemplate_NoAuth(bool useProgramMain, bool noHttps) { var project = await ProjectFactory.CreateProject(Output); var args = useProgramMain ? noHttps ? new[] { ArgConstants.UseProgramMain, ArgConstants.NoHttps } : new[] { ArgConstants.UseProgramMain } : noHttps ? new[] { ArgConstants.NoHttps } : null; var createResult = await project.RunDotNetNewAsync("razor", args : args); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("razor", project, createResult)); var expectedLaunchProfileNames = noHttps ? new[] { "http", "IIS Express" } : new[] { "http", "https", "IIS Express" }; await project.VerifyLaunchSettings(expectedLaunchProfileNames); var projectFileContents = ReadFile(project.TemplateOutputDir, $"{project.ProjectName}.csproj"); Assert.DoesNotContain(".db", projectFileContents); Assert.DoesNotContain("Microsoft.EntityFrameworkCore.Tools", projectFileContents); Assert.DoesNotContain("Microsoft.VisualStudio.Web.CodeGeneration.Design", projectFileContents); Assert.DoesNotContain("Microsoft.EntityFrameworkCore.Tools.DotNet", projectFileContents); Assert.DoesNotContain("Microsoft.Extensions.SecretManager.Tools", projectFileContents); var publishResult = await project.RunDotNetPublishAsync(); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, createResult)); // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build // later, while the opposite is not true. var buildResult = await project.RunDotNetBuildAsync(); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, createResult)); var pages = new List <Page> { new Page { Url = PageUrls.HomeUrl, Links = new [] { PageUrls.HomeUrl, PageUrls.HomeUrl, PageUrls.PrivacyUrl, PageUrls.DocsUrl, PageUrls.PrivacyUrl } }, new Page { Url = PageUrls.PrivacyUrl, Links = new [] { PageUrls.HomeUrl, PageUrls.HomeUrl, PageUrls.PrivacyUrl, PageUrls.PrivacyUrl } } }; using (var aspNetProcess = project.StartBuiltProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); await aspNetProcess.AssertPagesOk(pages); } using (var aspNetProcess = project.StartPublishedProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", project, aspNetProcess.Process)); await aspNetProcess.AssertPagesOk(pages); } }
private async Task RazorPagesTemplate_IndividualAuth_Core(bool useLocalDB, bool useProgramMain, bool noHttps) { var project = await ProjectFactory.CreateProject(Output); var args = useProgramMain ? noHttps ? new[] { ArgConstants.UseProgramMain, ArgConstants.NoHttps } : new[] { ArgConstants.UseProgramMain } : noHttps ? new[] { ArgConstants.NoHttps } : null; var createResult = await project.RunDotNetNewAsync("razor", auth : "Individual", useLocalDB : useLocalDB, args : args); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult)); // Individual auth supports no https OK var expectedLaunchProfileNames = noHttps ? new[] { "http", "IIS Express" } : new[] { "http", "https", "IIS Express" }; await project.VerifyLaunchSettings(expectedLaunchProfileNames); var projectFileContents = ReadFile(project.TemplateOutputDir, $"{project.ProjectName}.csproj"); if (!useLocalDB) { Assert.Contains(".db", projectFileContents); } var publishResult = await project.RunDotNetPublishAsync(); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult)); // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build // later, while the opposite is not true. var buildResult = await project.RunDotNetBuildAsync(); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult)); var migrationsResult = await project.RunDotNetEfCreateMigrationAsync("razorpages"); Assert.True(0 == migrationsResult.ExitCode, ErrorMessages.GetFailedProcessMessage("run EF migrations", project, migrationsResult)); project.AssertEmptyMigration("razorpages"); // Note: if any links are updated here, MvcTemplateTest.cs should be updated as well var pages = new List <Page> { new Page { Url = PageUrls.ForgotPassword, Links = new [] { PageUrls.HomeUrl, PageUrls.HomeUrl, PageUrls.PrivacyUrl, PageUrls.RegisterUrl, PageUrls.LoginUrl, PageUrls.PrivacyUrl } }, new Page { Url = PageUrls.HomeUrl, Links = new [] { PageUrls.HomeUrl, PageUrls.HomeUrl, PageUrls.PrivacyUrl, PageUrls.RegisterUrl, PageUrls.LoginUrl, PageUrls.DocsUrl, PageUrls.PrivacyUrl } }, new Page { Url = PageUrls.PrivacyUrl, Links = new [] { PageUrls.HomeUrl, PageUrls.HomeUrl, PageUrls.PrivacyUrl, PageUrls.RegisterUrl, PageUrls.LoginUrl, PageUrls.PrivacyUrl } }, new Page { Url = PageUrls.LoginUrl, Links = new [] { PageUrls.HomeUrl, PageUrls.HomeUrl, PageUrls.PrivacyUrl, PageUrls.RegisterUrl, PageUrls.LoginUrl, PageUrls.ForgotPassword, PageUrls.RegisterUrl, PageUrls.ResendEmailConfirmation, PageUrls.ExternalArticle, PageUrls.PrivacyUrl } }, new Page { Url = PageUrls.RegisterUrl, Links = new [] { PageUrls.HomeUrl, PageUrls.HomeUrl, PageUrls.PrivacyUrl, PageUrls.RegisterUrl, PageUrls.LoginUrl, PageUrls.ExternalArticle, PageUrls.PrivacyUrl } } }; using (var aspNetProcess = project.StartBuiltProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); await aspNetProcess.AssertPagesOk(pages); } using (var aspNetProcess = project.StartPublishedProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); await aspNetProcess.AssertPagesOk(pages); } }
private Project CreateProjectWithDefaultNameAndDefaultCalendar(IProjectCalendar calendar) { ProjectFactory projectFactory = new ProjectFactory(calendarFactory); return(projectFactory.CreateProject(calendar, VALID_PROJECT_NAME)); }
private async Task MvcTemplateCore(string languageOverride, string[] args = null) { var project = await ProjectFactory.CreateProject(Output); var createResult = await project.RunDotNetNewAsync("mvc", language : languageOverride, args : args); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult)); var noHttps = args?.Contains(ArgConstants.NoHttps) ?? false; var expectedLaunchProfileNames = noHttps ? new[] { "http", "IIS Express" } : new[] { "http", "https", "IIS Express" }; await project.VerifyLaunchSettings(expectedLaunchProfileNames); var projectExtension = languageOverride == "F#" ? "fsproj" : "csproj"; var projectFileContents = project.ReadFile($"{project.ProjectName}.{projectExtension}"); Assert.DoesNotContain(".db", projectFileContents); Assert.DoesNotContain("Microsoft.EntityFrameworkCore.Tools", projectFileContents); Assert.DoesNotContain("Microsoft.VisualStudio.Web.CodeGeneration.Design", projectFileContents); Assert.DoesNotContain("Microsoft.EntityFrameworkCore.Tools.DotNet", projectFileContents); Assert.DoesNotContain("Microsoft.Extensions.SecretManager.Tools", projectFileContents); // Avoid the F# compiler. See https://github.com/dotnet/aspnetcore/issues/14022 if (languageOverride != null) { return; } var publishResult = await project.RunDotNetPublishAsync(); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult)); // Run dotnet build after publish. The reason is that one uses Config = Debug and the other uses Config = Release // The output from publish will go into bin/Release/netcoreappX.Y/publish and won't be affected by calling build // later, while the opposite is not true. var buildResult = await project.RunDotNetBuildAsync(); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult)); IEnumerable <string> menuLinks = new List <string> { PageUrls.HomeUrl, PageUrls.HomeUrl, PageUrls.PrivacyFullUrl }; var footerLinks = new string[] { PageUrls.PrivacyFullUrl }; var pages = new List <Page> { new Page { Url = PageUrls.HomeUrl, Links = menuLinks.Append(PageUrls.DocsUrl).Concat(footerLinks) }, new Page { Url = PageUrls.PrivacyFullUrl, Links = menuLinks.Concat(footerLinks) } }; using (var aspNetProcess = project.StartBuiltProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); await aspNetProcess.AssertPagesOk(pages); } using (var aspNetProcess = project.StartPublishedProjectAsync()) { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", project, aspNetProcess.Process)); await aspNetProcess.AssertPagesOk(pages); } }
private Project CreateProject() { return(projectFactory.CreateProject(VALID_PROJECT_NAME)); }
public async Task GrpcTemplate(bool useProgramMain) { var project = await ProjectFactory.CreateProject(Output); var args = useProgramMain ? new[] { ArgConstants.UseProgramMain } : null; var createResult = await project.RunDotNetNewAsync("grpc", args : args); Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult)); var expectedLaunchProfileNames = new[] { "http", "https" }; await project.VerifyLaunchSettings(expectedLaunchProfileNames); var publishResult = await project.RunDotNetPublishAsync(); Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", project, publishResult)); var buildResult = await project.RunDotNetBuildAsync(); Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", project, buildResult)); var isOsx = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); var isWindowsOld = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && Environment.OSVersion.Version < new Version(6, 2); var unsupported = isOsx || isWindowsOld; using (var serverProcess = project.StartBuiltProjectAsync(hasListeningUri: !unsupported, logger: Logger)) { // These templates are HTTPS + HTTP/2 only which is not supported on Mac due to missing ALPN support. // https://github.com/dotnet/aspnetcore/issues/11061 if (isOsx) { serverProcess.Process.WaitForExit(assertSuccess: false); Assert.True(serverProcess.Process.HasExited, "built"); Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on macOS due to missing ALPN support.", ErrorMessages.GetFailedProcessMessageOrEmpty("Run built service", project, serverProcess.Process)); } else if (isWindowsOld) { serverProcess.Process.WaitForExit(assertSuccess: false); Assert.True(serverProcess.Process.HasExited, "built"); Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support.", ErrorMessages.GetFailedProcessMessageOrEmpty("Run built service", project, serverProcess.Process)); } else { Assert.False( serverProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built service", project, serverProcess.Process)); } } using (var aspNetProcess = project.StartPublishedProjectAsync(hasListeningUri: !unsupported)) { // These templates are HTTPS + HTTP/2 only which is not supported on Mac due to missing ALPN support. // https://github.com/dotnet/aspnetcore/issues/11061 if (isOsx) { aspNetProcess.Process.WaitForExit(assertSuccess: false); Assert.True(aspNetProcess.Process.HasExited, "published"); Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on macOS due to missing ALPN support.", ErrorMessages.GetFailedProcessMessageOrEmpty("Run published service", project, aspNetProcess.Process)); } else if (isWindowsOld) { aspNetProcess.Process.WaitForExit(assertSuccess: false); Assert.True(aspNetProcess.Process.HasExited, "published"); Assert.Contains("System.NotSupportedException: HTTP/2 over TLS is not supported on Windows 7 due to missing ALPN support.", ErrorMessages.GetFailedProcessMessageOrEmpty("Run published service", project, aspNetProcess.Process)); } else { Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run published service", project, aspNetProcess.Process)); } } }