public void CanSearchJobPostWithTwoCategoryTest() { IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Lixa"; Employer returned = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Rua sem fim"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost testPost2 = new JobPost(); testPost2.Title = "Cortar Relva"; testPost2.Category = Categories.GARDENING; testPost2.Description = "Isto parece a amazonia!"; testPost2.Tradable = true; testPost2.InitialPrice = 60.6; testPost2.Address = "Rua sem fim"; testPost2.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; jobPostDAO.Create(returned.Id, testPost); jobPostDAO.Create(returned.Id, testPost2); Categories[] categories = { Categories.PLUMBING, Categories.GARDENING }; List <JobPostReturnedModel> jobPosts = jobPostDAO.GetJobs(categories, "", null, null, 1); JobPostReturnedModel[] jobPostsArray = jobPosts.ToArray(); Assert.Equal("Canalização Estourada", jobPostsArray[0].Title); Assert.Equal(Categories.PLUMBING, jobPostsArray[0].Category); Assert.Equal("Grande estouro nos canos da sanita", jobPostsArray[0].Description); Assert.True(jobPostsArray[0].Tradable); Assert.Equal(60.6, jobPostsArray[0].InitialPrice); Assert.Equal("Rua sem fim", jobPostsArray[0].Address); Assert.Equal("Cortar Relva", jobPostsArray[1].Title); Assert.Equal(Categories.GARDENING, jobPostsArray[1].Category); Assert.Equal("Isto parece a amazonia!", jobPostsArray[1].Description); Assert.True(jobPostsArray[1].Tradable); Assert.Equal(60.6, jobPostsArray[1].InitialPrice); Assert.Equal("Rua sem fim", jobPostsArray[1].Address); _fixture.Dispose(); }
public void CanSearchJobPostWithOneCategoryWithDistanceAndAddressTest() { IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Rua Eng. Luís Carneiro Leão, Figueiró"; Employer returned = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Rua de Salgueiros, Penafiel"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost testPost2 = new JobPost(); testPost2.Title = "Canalização Estourada"; testPost2.Category = Categories.PLUMBING; testPost2.Description = "Grande estouro nos canos da sanita"; testPost2.Tradable = true; testPost2.InitialPrice = 60.6; testPost2.Address = "London"; testPost2.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; jobPostDAO.Create(returned.Id, testPost); jobPostDAO.Create(returned.Id, testPost2); Categories[] categories = { Categories.PLUMBING }; List <JobPostReturnedModel> jobPosts = jobPostDAO.GetJobs(categories, testEmployer.Address, 400, null, 1); JobPostReturnedModel[] jobPostsArray = jobPosts.ToArray(); Assert.Equal("Canalização Estourada", jobPostsArray[0].Title); Assert.Equal(Categories.PLUMBING, jobPostsArray[0].Category); Assert.Equal("Grande estouro nos canos da sanita", jobPostsArray[0].Description); Assert.True(jobPostsArray[0].Tradable); Assert.Equal(60.6, jobPostsArray[0].InitialPrice); Assert.Equal("Rua de Salgueiros, Penafiel", jobPostsArray[0].Address); Assert.Single(jobPostsArray); _fixture.Dispose(); }
public void CanFindJobPostByIdOrReturnNullWhenNotFoundTest() { IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Lixa"; Employer returned = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Rua sem fim"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost returnedPost = jobPostDAO.Create(returned.Id, testPost); Assert.Equal(returnedPost.Id, jobPostDAO.FindById(returnedPost.Id).Id); //when not found Assert.Null(jobPostDAO.FindById(200)); _fixture.Dispose(); }
public void CanReturnJobPostsFromEmployerTest() { IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Lixa"; Employer returned = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Rua sem fim"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost testPost2 = new JobPost(); testPost2.Title = "Cortar Relva"; testPost2.Category = Categories.GARDENING; testPost2.Description = "Isto parece a amazonia!"; testPost2.Tradable = true; testPost2.InitialPrice = 60.6; testPost2.Address = "Rua sem fim"; testPost2.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; jobPostDAO.Create(returned.Id, testPost); jobPostDAO.Create(returned.Id, testPost2); List <JobPost> returnedList = jobPostDAO.GetEmployerPosts(returned.Id); Assert.Equal(2, returnedList.Count); Assert.Equal(testPost.Id, returnedList.Find(a => a.Id == testPost.Id).Id); Assert.Equal(testPost2.Id, returnedList.Find(a => a.Id == testPost2.Id).Id); _fixture.Dispose(); }
public void CanMakeOfferOnJobWithoutPriceTest() { IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Lixa"; Employer returned = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Rua sem fim"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost jobReturned = jobPostDAO.Create(returned.Id, testPost); IMateDAO <Mate> MateDAO = new MateDAO(_connection); Mate testMate = new Mate(); testMate.FirstName = "Miguel"; testMate.LastName = "Dev"; testMate.UserName = "******"; testMate.Password = "******"; testMate.Email = "*****@*****.**"; testMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testMate.Address = "Figueiró"; testMate.Categories = new[] { Categories.CLEANING, Categories.PLUMBING }; testMate.Rank = Ranks.SUPER_MATE; testMate.Range = 20; Mate returnedMate = MateDAO.Create(testMate); Offer mateOffer = new Offer(); mateOffer.Price = 0; mateOffer.JobPost = jobReturned; Offer offer = jobPostDAO.makeOfferOnJob(mateOffer, returnedMate.Id); //Verificar que o preço foi estabelicido com o default Assert.Equal(testPost.InitialPrice, offer.Price); Assert.Equal(mateOffer.JobPost.Id, offer.JobPost.Id); Assert.False(offer.Approved); _fixture.Dispose(); }
public void ReturnEmptyWhenSearchJobWithWrongLocationTest() { IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Rua Eng. Luís Carneiro Leão, Figueiró"; Employer returned = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Rua sem fim"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost jobReturned = jobPostDAO.Create(returned.Id, testPost); IMateDAO <Mate> MateDAO = new MateDAO(_connection); Mate testMate = new Mate(); testMate.FirstName = "Miguel"; testMate.LastName = "Dev"; testMate.UserName = "******"; testMate.Password = "******"; testMate.Email = "*****@*****.**"; testMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testMate.Address = "Random City"; testMate.Categories = new[] { Categories.CLEANING, Categories.PLUMBING }; testMate.Rank = Ranks.SUPER_MATE; testMate.Range = 20; Mate returnedMate = MateDAO.Create(testMate); Offer mateOffer = new Offer(); mateOffer.Price = 20; mateOffer.Approved = false; mateOffer.JobPost = jobReturned; Offer offer = jobPostDAO.makeOfferOnJob(mateOffer, returnedMate.Id); Categories[] categories = { Categories.PLUMBING }; Assert.Empty(jobPostDAO.GetJobs(categories, testMate.Address, 400, null, returnedMate.Id)); _fixture.Dispose(); }
public void CanIgnoreValidJobTest() { IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Rua Eng. Luís Carneiro Leão, Nº 54 4590-244 Porto, Portugal"; Employer returned = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Rua de Salgueiros, Penafiel"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost jobReturned = jobPostDAO.Create(returned.Id, testPost); IMateDAO <Mate> MateDAO = new MateDAO(_connection); Mate testMate = new Mate(); testMate.FirstName = "Miguel"; testMate.LastName = "Dev"; testMate.UserName = "******"; testMate.Password = "******"; testMate.Email = "*****@*****.**"; testMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testMate.Address = "Rua de Salgueiros, Penafiel"; testMate.Categories = new[] { Categories.CLEANING, Categories.PLUMBING }; testMate.Rank = Ranks.SUPER_MATE; testMate.Range = 20; Mate returnedMate = MateDAO.Create(testMate); IgnoredJobModel job = new IgnoredJobModel(); job.Id = jobReturned.Id; Assert.True(MateDAO.IgnoreJobPost(returnedMate.Id, job)); Categories[] categories = { Categories.PLUMBING }; Assert.Empty(jobPostDAO.GetJobs(categories, testMate.Address, 400, null, returnedMate.Id)); _fixture.Dispose(); }
public void CanUpdatePostDetailsTest() { IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Lixa"; Employer returned = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.ImagePath = "path/image"; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Rua sem fim"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost jobReturned = jobPostDAO.Create(returned.Id, testPost); //Change variables from old post to new ones JobPost OldPost = jobReturned; OldPost.Id = jobReturned.Id; OldPost.Title = "Cadeira dificil de Montar"; OldPost.Category = Categories.FURNITURE_ASSEMBLE; OldPost.ImagePath = ""; OldPost.Description = "Cadeira super complicada"; OldPost.Tradable = true; OldPost.InitialPrice = 63.6; OldPost.Address = "Rua com fim"; OldPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost newPost = jobPostDAO.UpdatePostDetails(OldPost); Assert.Equal(OldPost.Title, newPost.Title); Assert.Equal(OldPost.Category, newPost.Category); Assert.Equal(OldPost.ImagePath, newPost.ImagePath); Assert.Equal(OldPost.Description, newPost.Description); Assert.Equal(OldPost.Tradable, newPost.Tradable); Assert.Equal(OldPost.InitialPrice, newPost.InitialPrice); Assert.Equal(OldPost.Address, newPost.Address); _fixture.Dispose(); }
public void CanAddPaymentTypeTest() { IEmployerDAO <Employer> employerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Ema"; testEmployer.LastName = "Coelho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Lousada"; Employer returnedEmployer = employerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.ImagePath = "path/image"; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Lousada"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost jobReturned = jobPostDAO.Create(returnedEmployer.Id, testPost); PaymentModel paymentModel = new PaymentModel(); paymentModel.payments = Payment.MBWAY; PaymentModel[] payments = { paymentModel }; jobPostDAO.AddPayment(jobReturned.Id, payments); JobPost post = jobPostDAO.FindById(jobReturned.Id); Assert.Contains(Payment.MBWAY, post.PaymentMethod); _fixture.Dispose(); }
public ActionResult <JobPost> Create(JobPostModel model) { try { int?employerID = ClaimHelper.GetIdFromClaimIdentity((ClaimsIdentity)this.ControllerContext.HttpContext.User.Identity); if (employerID == null) { return(Unauthorized()); } JobPost post = _mapper.Map <JobPost>(model); IJobDAO JobPostDAO = new JobDAO(_connection); JobPost JobPosts = JobPostDAO.Create((int)employerID, post); return(Ok(JobPosts)); } catch (Exception ex) { return(BadRequest(new ErrorMessageModel(ex.Message))); } }
/* * CRUD + LIST */ #region CREATE public virtual OperationResult Create(Job job) { try { using var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled); _dao.Create(job); transactionScope.Complete(); return(new OperationResult <List <Job> >() { Success = true }); } catch (Exception e) { return(new OperationResult <List <Job> >() { Success = false, Exception = e }); } }
public void CanCreateJobPostTest() { IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Lixa"; Employer returned = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.ImagePath = "path/image"; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Rua sem fim"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost jobReturned = jobPostDAO.Create(returned.Id, testPost); Assert.Equal(testPost.Title, jobReturned.Title); Assert.Equal(testPost.Category, jobReturned.Category); Assert.Equal(testPost.ImagePath, jobReturned.ImagePath); Assert.Equal(testPost.Description, jobReturned.Description); Assert.Equal(testPost.Tradable, jobReturned.Tradable); Assert.Equal(testPost.InitialPrice, jobReturned.InitialPrice); Assert.Equal(testPost.Address, jobReturned.Address); Assert.Equal(testPost.PaymentMethod, jobReturned.PaymentMethod); _fixture.Dispose(); }
public void CanDeleteJobPostTest() { IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Lixa"; Employer returned = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Aberta"; testPost.Category = Categories.PLUMBING; testPost.Description = "Cozinha sem canalização"; testPost.Tradable = true; testPost.InitialPrice = 66.6; testPost.Address = "Rua aberta"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost returnedPost = jobPostDAO.Create(returned.Id, testPost); //Delete Assert.True(jobPostDAO.Delete(returnedPost)); //After delete Categories[] categories = { }; List <JobPostReturnedModel> jobPosts = jobPostDAO.GetJobs(categories, null, null, null, 1); Assert.Empty(jobPosts); _fixture.Dispose(); }
public void ReturnFalseWhenDeleteNonExistentWorkTest() { IMateDAO <Mate> MateDAO = new MateDAO(_connection); Mate testMate = new Mate(); testMate.FirstName = "Miguel"; testMate.LastName = "Dev"; testMate.UserName = "******"; testMate.Password = "******"; testMate.Email = "*****@*****.**"; testMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testMate.Address = "Figueiró"; testMate.Categories = new[] { Categories.CLEANING, Categories.PLUMBING }; testMate.Rank = Ranks.SUPER_MATE; testMate.Range = 20; Mate returned = MateDAO.Create(testMate); IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Lixa"; Employer returnedEmp = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.ImagePath = "path/image"; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Rua sem fim"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; JobPost jobReturned = jobPostDAO.Create(returnedEmp.Id, testPost); DateTime date = new DateTime(2020, 01, 16); Job job = new Job(); job.Date = date; job.Mate = returned.Id; job.JobPost = jobReturned.Id; job.FinishedConfirmedByEmployer = false; job.FinishedConfirmedByMate = false; job.Employer = returnedEmp.Id; IWorkDAO workDAO = new WorkDAO(_connection); Job created = workDAO.Create(returnedEmp.Id, job); Assert.False(workDAO.Delete(999)); _fixture.Dispose(); }
public void CanSearchJobPostWithRatingTest() { IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer(); testEmployer.FirstName = "Marcelo"; testEmployer.LastName = "Carvalho"; testEmployer.UserName = "******"; testEmployer.Password = "******"; testEmployer.Email = "*****@*****.**"; testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testEmployer.Address = "Lixa"; testEmployer.AverageRating = 5; Employer returned = EmployerDAO.Create(testEmployer); IMateDAO <Mate> MateDAO = new MateDAO(_connection); Mate testMate = new Mate(); testMate.FirstName = "Miguel"; testMate.LastName = "Dev"; testMate.UserName = "******"; testMate.Password = "******"; testMate.Email = "*****@*****.**"; testMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."; testMate.Address = "Figueiró"; testMate.Categories = new[] { Categories.CLEANING, Categories.PLUMBING }; testMate.Rank = Ranks.SUPER_MATE; testMate.Range = 20; Mate returnedMate = MateDAO.Create(testMate); Review review = new Review(); review.Rating = 4.5d; ReviewEmployerDAO reviewDAO = new ReviewEmployerDAO(_connection); reviewDAO.ReviewEmployer(returned.Id, review); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost(); testPost.Title = "Canalização Estourada"; testPost.Category = Categories.PLUMBING; testPost.Description = "Grande estouro nos canos da sanita"; testPost.Tradable = true; testPost.InitialPrice = 60.6; testPost.Address = "Rua sem fim"; testPost.PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY }; jobPostDAO.Create(returned.Id, testPost); Categories[] categories = { Categories.PLUMBING, Categories.GARDENING }; List <JobPostReturnedModel> jobPosts = jobPostDAO.GetJobs(categories, null, null, 4, 1); JobPostReturnedModel[] jobPostsArray = jobPosts.ToArray(); Assert.Equal("Canalização Estourada", jobPostsArray[0].Title); Assert.Equal(Categories.PLUMBING, jobPostsArray[0].Category); Assert.Equal("Grande estouro nos canos da sanita", jobPostsArray[0].Description); Assert.True(jobPostsArray[0].Tradable); Assert.Equal(60.6, jobPostsArray[0].InitialPrice); Assert.Equal("Rua sem fim", jobPostsArray[0].Address); Assert.Single(jobPostsArray); _fixture.Dispose(); }
public void CanMakePaymentPayPalTest() { IMateDAO <Mate> MateDAO = new MateDAO(_connection); Mate testMate = new Mate { FirstName = "Miguel", LastName = "Dev", UserName = "******", Password = "******", Email = "*****@*****.**", Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.", Address = "Figueiró", Categories = new[] { Categories.CLEANING, Categories.PLUMBING }, Rank = Ranks.SUPER_MATE, Range = 20 }; Mate returned = MateDAO.Create(testMate); IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection); Employer testEmployer = new Employer { FirstName = "Marcelo", LastName = "Carvalho", UserName = "******", Password = "******", Email = "*****@*****.**", Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.", Address = "Lixa" }; Employer returnedEmp = EmployerDAO.Create(testEmployer); IJobDAO jobPostDAO = new JobDAO(_connection); JobPost testPost = new JobPost { Title = "Canalização Estourada", Category = Categories.PLUMBING, ImagePath = "path/image", Description = "Grande estouro nos canos da sanita", Tradable = false, InitialPrice = 60.6, Address = "Rua sem fim", PaymentMethod = new[] { Payment.PAYPAL, Payment.MONEY } }; JobPost jobReturned = jobPostDAO.Create(returnedEmp.Id, testPost); DateTime date = new DateTime(2020, 01, 16); Job job = new Job { Date = date, Mate = returned.Id, JobPost = jobReturned.Id, FinishedConfirmedByEmployer = false, FinishedConfirmedByMate = false, Employer = returnedEmp.Id }; IWorkDAO workDAO = new WorkDAO(_connection); Job returnedJob = workDAO.Create(returnedEmp.Id, job); workDAO.MarkJobAsDone(returnedJob.Id, returnedEmp.Id); workDAO.MarkJobAsDone(returnedJob.Id, returned.Id); Invoice invoice = new Invoice { Value = 60.6, PaymentType = Payment.PAYPAL }; string email = "*****@*****.**"; string paypalLink = String.Format("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&amount={0}¤cy_code=EUR&business={1}&item_name={2}&return=Page", testPost.InitialPrice, email, testPost.Title); PaymentDAO paymentDAO = new PaymentDAO(_connection); Invoice result = paymentDAO.makePayment(invoice, returnedJob.Id, returnedEmp.Id); Assert.Equal(invoice.Value, result.Value); Assert.Equal(invoice.PaymentType, result.PaymentType); Assert.False(result.ConfirmedPayment); Assert.Equal(paypalLink, result.Link); _fixture.Dispose(); }