private async Task CreateProject_ShouldCorrectlyAddProject() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); var userManager = this.GetMockUserManager().Object; this.adminService = new AdminService(userManager, context); var model = new ProjectCreateInputModel { Designer = new ApplicationUser { Email = "*****@*****.**", PasswordHash = 5.GetHashCode().ToString(), }, Customer = new ApplicationUser { Email = "*****@*****.**", PasswordHash = 5.GetHashCode().ToString(), }, Name = "Test1", IsPublic = true, }; var result = await this.adminService.CreateProject(model); Assert.Equal("New project created successfuly!", result.ToString()); }
private async Task CreateReview_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); this.reviewService = new ReviewService(context); var review = new ProjectReview { ProjectId = "bb2bd817-98cd-4cf3-a80a-53ea0cd9c200", CustomerId = new Guid("cb2bd817-98cd-4cf3-a80a-53ea0cd9c200").ToString(), Review = "Second Review", }; var reviewCreate = new ReviewCreateModel { CustomerId = review.CustomerId, ProjectId = review.ProjectId, Review = "Second Review Text", }; var result = await this.reviewService.CreateReview(reviewCreate); Assert.Equal("Review was successfully created!", result); }
private async Task GetAllCompletedProjects_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); var userManager = this.GetMockUserManager().Object; this.adminService = new AdminService(userManager, context); var project = await this.adminService.GetAllProjectsInProgress(); var projectInputModel = new ProjectEditInputModel { Id = project[0].Id, IsPublic = project[0].IsPublic, Name = "Test-Edited", Status = ProjectStatus.Completed, }; await this.adminService.EditProject(projectInputModel); var completedProjects = await this.adminService.GetAllCompletedProjects(); Assert.Single(completedProjects); }
private async Task AddDesignReference_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); this.designBoardServce = new DesignBoardService(context); var designBoard = new DesignBoardCreateInputModel { ProjectId = "bb2bd817-98cd-4cf3-a80a-53ea0cd9c200", CustomerId = new Guid("cb2bd817-98cd-4cf3-a80a-53ea0cd9c200").ToString(), Name = "Test Design Board", }; var designRefernce = new ReferenceInputModel { CustomerId = new Guid("cb2bd817-98cd-4cf3-a80a-53ea0cd9c200").ToString(), ImageUrl = "https://test.test", DesignBoardId = "de2bd817-98cd-4cf3-a80a-53ea0cd9c200", }; await this.designBoardServce.AddDesignBoard(designBoard); var result = await this.designBoardServce.AddDesignReference(designRefernce); Assert.Equal("DesignReference created successfully!", result); }
private async Task GetActiveCustomerProjects_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); this.projectService = new ProjectService(context); var result = this.projectService.GetActiveCustomerProjects("cb2bd817-98cd-4cf3-a80a-53ea0cd9c200"); Assert.Single(result); }
private async Task GetCurrentProjectFiles_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); this.projectService = new ProjectService(context); var result = await this.projectService.GetCurrentProjectFiles("bb2bd817-98cd-4cf3-a80a-53ea0cd9c200"); Assert.Equal(1, result.Count); }
public async Task GetPublicProjects_ShouldReturnCorrectNumber() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); this.portfolioService = new PortfolioService(context); var result = this.portfolioService.GetPublicProjectFiles().Count; Assert.Equal(2, result); }
public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var serviceProvider = scope.ServiceProvider; ContextInitializer.InitializeContext(serviceProvider); } host.Run(); }
private async Task GetCurrentDesignBoard_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); this.designBoardServce = new DesignBoardService(context); var result = await this.designBoardServce.GetCurrentDesignBoard("bb2bd817-98cd-4cf3-a80a-53ea0cd9c330"); Assert.Equal("Test Design Board", result.Name); }
private async Task GetDesignBoardReferences_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); this.designBoardServce = new DesignBoardService(context); var result = await this.designBoardServce.GetDesignBoardReferences("bb2bd817-98cd-4cf3-a80a-53ea0cd9c330"); Assert.Equal(1, result.Count); }
private async Task GetAllProjectsInProgress_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); var userManager = this.GetMockUserManager().Object; this.adminService = new AdminService(userManager, context); var project = await this.adminService.GetAllProjectsInProgress(); Assert.Single(project); }
private async Task GetCurrentProject_ShouldReturnNull() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); var cloudinary = new Mock <CloudinaryService>().Object; this.projectFileService = new ProjectFileService(cloudinary, context); var result = await this.projectFileService.GetCurrentProjectFile("ab3bd817-98cd-4cf3-a80a-53ea0cd9c200"); Assert.Null(result); }
private async Task GetCurrentProjectDesignBoards_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); this.projectService = new ProjectService(context); var result = await this.projectService.GetCurrentProjectDesignBoards("bb2bd817-98cd-4cf3-a80a-53ea0cd9c200"); var designReferenceUrl = result[0].DesignReferences.FirstOrDefault().ImageUrl; Assert.Equal(1, result[0].DesignReferences.Count); Assert.Equal("https://test.test", designReferenceUrl); }
private async Task CreateProject_ShouldThrowExeption() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); var userManager = this.GetMockUserManager().Object; this.adminService = new AdminService(userManager, context); var test1 = new ProjectCreateInputModel { Designer = new ApplicationUser { Email = "*****@*****.**", PasswordHash = 5.GetHashCode().ToString(), }, Customer = new ApplicationUser { Email = "*****@*****.**", PasswordHash = 5.GetHashCode().ToString(), }, Name = "Test", IsPublic = true, }; var test2 = new ProjectCreateInputModel { Designer = new ApplicationUser { Email = "*****@*****.**", PasswordHash = 5.GetHashCode().ToString(), }, Customer = new ApplicationUser { Email = "*****@*****.**", PasswordHash = 5.GetHashCode().ToString(), }, Name = "Test", IsPublic = true, }; await this.adminService.CreateProject(test1); var result2 = await this.adminService.CreateProject(test2); Assert.Equal("Project with name Test alreday exists!", result2.ToString()); }
private async Task GetCurrentProject_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); var cloudinary = new Mock <CloudinaryService>().Object; this.projectFileService = new ProjectFileService(cloudinary, context); var result = await this.projectFileService.GetCurrentProjectFile("ab2bd817-98cd-4cf3-a80a-53ea0cd9c200"); Assert.Equal("TestProjectFile.jpg", result.Name); Assert.True(result.IsPublic); Assert.False(result.IsApproved); }
private async Task DeleteProject_ShouldWorkFine() { var context = ContextInitializer.InitializeContext(); await this.SeedData(context); var userManager = this.GetMockUserManager().Object; this.adminService = new AdminService(userManager, context); var project = await this.adminService.GetAllProjectsInProgress(); await this.adminService.DeleteProject(project[0].Id); var result = await this.adminService.GetAllProjectsInProgress(); Assert.Empty(result); }