예제 #1
0
        public void CanGetEmployerWithDescriptionByIdTest()
        {
            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);

            Employer e = employerDAO.FindEmployerById(returnedEmployer.Id);

            Assert.Equal(returnedEmployer.Id, e.Id);
            Assert.Equal(returnedEmployer.UserName, e.UserName);
            Assert.Equal(returnedEmployer.FirstName, e.FirstName);
            Assert.Equal(returnedEmployer.LastName, e.LastName);
            Assert.Equal(returnedEmployer.Email, e.Email);
            Assert.Equal(returnedEmployer.Address, e.Address);
            Assert.Equal(returnedEmployer.Description, e.Description);

            _fixture.Dispose();
        }
예제 #2
0
        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();
        }
예제 #3
0
        public void CanMateAddRatingTest()
        {
            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);

            IReviewEmployerDAO ReviewEmployerDAO = new ReviewEmployerDAO(_connection);
            Review             reviewsTest       = new Review();

            reviewsTest.Id     = 5;
            reviewsTest.Rating = 4;

            Review revReturned = ReviewEmployerDAO.ReviewEmployer(returned.Id, reviewsTest);

            Assert.Equal(reviewsTest.Id, revReturned.Id);
            Assert.Equal(reviewsTest.Rating, revReturned.Rating);

            _fixture.Dispose();
        }
예제 #4
0
        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 CanGetEmployerWithoutDescriptionByIdTest()
        {
            IEmployerDAO <Employer> employerDAO = new EmployerDAO(_connection);
            Employer testEmployer = new Employer();

            testEmployer.FirstName = "Ema";
            testEmployer.LastName  = "Coelho";
            testEmployer.UserName  = "******";
            testEmployer.Password  = "******";
            testEmployer.Email     = "*****@*****.**";
            testEmployer.Address   = "Lousada";

            Employer returnedEmployer = employerDAO.Create(testEmployer);

            Employer e = employerDAO.FindEmployerById(returnedEmployer.Id);

            Assert.Equal(returnedEmployer.Id, e.Id);
            Assert.Equal(returnedEmployer.UserName, e.UserName);
            Assert.Equal(returnedEmployer.FirstName, e.FirstName);
            Assert.Equal(returnedEmployer.LastName, e.LastName);
            Assert.Equal(returnedEmployer.Email, e.Email);
            Assert.Equal(returnedEmployer.Address, e.Address);

            _fixture.Dispose();
        }
        public void CanEmployerUpdateProfileTest()
        {
            IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection);
            Employer testEmployer = new Employer();

            testEmployer.FirstName   = "Jessica";
            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     = "Ordem";

            Employer returned = EmployerDAO.Create(testEmployer);

            returned.FirstName   = "Ema";
            returned.LastName    = "Coelho";
            returned.UserName    = "******";
            returned.Description = "Sou um empregador!";
            returned.Address     = "Lousada";

            Employer updated = EmployerDAO.Update(returned, returned.Id);

            Assert.Equal(returned.FirstName, updated.FirstName);
            Assert.Equal(returned.LastName, updated.LastName);
            Assert.Equal(returned.UserName, updated.UserName);
            Assert.Equal(returned.Description, updated.Description);
            Assert.Equal(returned.Address, updated.Address);

            _fixture.Dispose();
        }
        public void CanRegisterEmployerTest()
        {
            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);

            Assert.Equal(testEmployer.FirstName, returned.FirstName);
            Assert.Equal(testEmployer.LastName, returned.LastName);
            Assert.Equal(testEmployer.UserName, returned.UserName);
            Assert.Equal(testEmployer.Password, returned.Password);
            Assert.Equal(testEmployer.Email, returned.Email);
            Assert.Equal(testEmployer.Description, returned.Description);
            Assert.Equal(testEmployer.Address, returned.Address);

            _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();
        }
예제 #9
0
        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();
        }
예제 #10
0
        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();
        }
예제 #11
0
        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();
        }
예제 #13
0
        public void CanVerifyIfUserIsNotFromChatTest()
        {
            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);

            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);

            ChatDAO chatDao = new ChatDAO(_connection);

            int chatId = chatDao.CreateChatId();

            Chat chat = new Chat();

            chat.UserId = returned.Id;
            chat.ChatId = chatId;

            chatDao.CreateChat(chat);
            chat.UserId = returnedMate.Id;
            chatDao.CreateChat(chat);

            bool user1IsFromChat = chatDao.IsUserFromChat(999999999, returned.Id);
            bool user2IsFromChat = chatDao.IsUserFromChat(999999999, returnedMate.Id);

            Assert.False(user1IsFromChat);
            Assert.False(user2IsFromChat);

            _fixture.Dispose();
        }
        public void CanUserAddReportTest()
        {
            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);

            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 returnedEmployer = EmployerDAO.Create(testEmployer);

            IReportDAO ReportDAO  = new ReportDAO(_connection);
            Report     reportTest = new Report();

            reportTest.Id         = 1;
            reportTest.Reason     = Reasons.INADEQUATE_BEHAVIOUR;
            reportTest.ReportedId = 35;
            reportTest.ReporterId = 34;
            reportTest.Comment    = "O trabalho que fez nao presta";

            Report repReturned = ReportDAO.ReportUser(returnedEmployer.Id, returnedMate.Id, reportTest);

            Assert.Equal(reportTest.Id, repReturned.Id);
            Assert.Equal(reportTest.Reason, repReturned.Reason);
            Assert.Equal(reportTest.ReportedId, repReturned.ReportedId);
            Assert.Equal(reportTest.ReporterId, repReturned.ReporterId);
            Assert.Equal(reportTest.Comment, repReturned.Comment);

            _fixture.Dispose();
        }
예제 #15
0
 public ActionResult <EmployerModel> Create(EmployerRegister regEmployer)
 {
     try
     {
         Employer employer = _mapper.Map <Employer>(regEmployer);
         IEmployerDAO <Employer> EmployerDAO   = new EmployerDAO(_connection);
         EmployerModel           employerModel = _mapper.Map <EmployerModel>(EmployerDAO.Create(employer));
         return(Ok(employerModel));
     }
     catch (Exception ex)
     {
         return(BadRequest(new ErrorMessageModel(ex.Message)));
     }
 }
        public void CanUpdateChatHubConnectionTest()
        {
            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);

            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);

            ChatDAO chatDao = new ChatDAO(_connection);

            chatDao.AddChatHubConnection(returned.Id, "connection1");
            chatDao.AddChatHubConnection(returnedMate.Id, "connection2");

            chatDao.UpdateChatHubConnection(returned.Id, "connection1Replaced");
            chatDao.UpdateChatHubConnection(returnedMate.Id, "connection2Replaced");

            ChatConnection connection1 = chatDao.GetChatConnectionFromUserId(returned.Id);
            ChatConnection connection2 = chatDao.GetChatConnectionFromUserId(returnedMate.Id);

            Assert.Equal("connection1Replaced", connection1.Connection);
            Assert.Equal(returned.Id, connection1.UserId);
            Assert.Equal("connection2Replaced", connection2.Connection);
            Assert.Equal(returnedMate.Id, connection2.UserId);

            _fixture.Dispose();
        }
예제 #17
0
        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 CanEmployerAddReviewTest()
        {
            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);

            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);

            IReviewMateDAO ReviewMateDAO = new ReviewMateDAO(_connection);
            MateReview     reviewsTest   = new MateReview();

            reviewsTest.Id      = 5;
            reviewsTest.Rating  = 4;
            reviewsTest.Comment = "O trolha fez um trabalho excelente!";

            MateReview revReturned = ReviewMateDAO.ReviewMate(returnedEmp.Id, returned.Id, reviewsTest);

            Assert.Equal(reviewsTest.Id, revReturned.Id);
            Assert.Equal(reviewsTest.Rating, revReturned.Rating);
            Assert.Equal(reviewsTest.Comment, revReturned.Comment);

            _fixture.Dispose();
        }
        public void ReturnExceptionCreatingChatWithUserId0Test()
        {
            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);

            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);

            ChatDAO chatDao = new ChatDAO(_connection);

            int chatId = chatDao.CreateChatId();

            Chat chat = new Chat();

            chat.UserId = 0;
            chat.ChatId = chatId;

            Assert.Throws <Exception>(() => chatDao.CreateChat(chat));

            _fixture.Dispose();
        }
예제 #20
0
        public void CanRegisterEmployerTest()
        {
            IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection);
            Employer testEmployer = new Employer();
            string   password     = testEmployer.Password;

            testEmployer.FirstName   = "Samuel";
            testEmployer.LastName    = "Cunha";
            testEmployer.UserName    = "******";
            testEmployer.Password    = "******";
            testEmployer.Email       = "*****@*****.**";
            testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
            testEmployer.Address     = "Aparecida";

            Employer returned = EmployerDAO.Create(testEmployer);

            Assert.True(PasswordOperations.VerifyHash("samuel123", returned.Password, returned.PasswordSalt));
            _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 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 CanEmployerRemoveFavoriteMateTest()
        {
            IMateDAO <Mate> MateDAO  = new MateDAO(_connection);
            Mate            testMate = new Mate();

            testMate.FirstName   = "Jessica";
            testMate.LastName    = "Coelho";
            testMate.UserName    = "******";
            testMate.Password    = "******";
            testMate.Email       = "*****@*****.**";
            testMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
            testMate.Address     = "Ordem";
            testMate.Categories  = new[] { Categories.FURNITURE_ASSEMBLE, Categories.TRANSPORTATION };
            testMate.Rank        = Ranks.MATE;
            testMate.Range       = 20;

            Mate returnedMate = MateDAO.Create(testMate);

            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);

            int?returnedId = employerDAO.AddFavorite(returnedEmployer.Id, returnedMate.Id);

            int?deletedID = employerDAO.RemoveFavorite(returnedEmployer.Id, returnedMate.Id);

            Assert.Equal(returnedMate.Id, deletedID);

            _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 CanEmployerListFavoriteMatesTest()
        {
            IMateDAO <Mate> MateDAO  = new MateDAO(_connection);
            Mate            testMate = new Mate();

            testMate.FirstName   = "Jessica";
            testMate.LastName    = "Coelho";
            testMate.UserName    = "******";
            testMate.Password    = "******";
            testMate.Email       = "*****@*****.**";
            testMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
            testMate.Address     = "Ordem";
            testMate.Categories  = new[] { Categories.FURNITURE_ASSEMBLE, Categories.TRANSPORTATION };
            testMate.Rank        = Ranks.MATE;
            testMate.Range       = 20;

            Mate returnedMate = MateDAO.Create(testMate);

            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);

            employerDAO.AddFavorite(returnedEmployer.Id, returnedMate.Id);

            List <FavoriteModel> favoriteModels = employerDAO.FavoritesList(returnedEmployer.Id).ToList();

            Assert.Equal(returnedMate.Email, favoriteModels.Find(a => a.Email == returnedMate.Email).Email);

            _fixture.Dispose();
        }
예제 #26
0
        public void CanFindByEmailTest()
        {
            IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection);
            Employer testEmployer = new Employer();
            string   password     = testEmployer.Password;

            testEmployer.FirstName   = "Samuel";
            testEmployer.LastName    = "Cunha";
            testEmployer.UserName    = "******";
            testEmployer.Password    = "******";
            testEmployer.Email       = "*****@*****.**";
            testEmployer.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
            testEmployer.Address     = "Aparecida";

            Employer returned = EmployerDAO.Create(testEmployer);

            UserDAO userDAO = new UserDAO(_connection);

            Assert.NotNull(userDAO.FindUserByEmail("*****@*****.**"));

            _fixture.Dispose();
        }
        public void ReturnExceptionWhenJobIDisInvalidOnMarkJobAsDoneTest()
        {
            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);

            IWorkDAO workDAO = new WorkDAO(_connection);

            Assert.Throws <Exception>(() => workDAO.MarkJobAsDone(1000, returnedEmp.Id));
            Assert.Throws <Exception>(() => workDAO.MarkJobAsDone(1000, returned.Id));

            _fixture.Dispose();
        }
        public void ReturnFalselWhenIgnoringAJobThatDoesntExistTest()
        {
            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);

            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);

            IgnoredJobModel job = new IgnoredJobModel();

            job.Id = 1000;

            Assert.False(MateDAO.IgnoreJobPost(returnedMate.Id, job));
            _fixture.Dispose();
        }
        public void FindUserByIdNullTest()
        {
            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);

            IUserDAO <User> userDAO = new UserDAO(_connection);

            User user = userDAO.FindById(returned.Id + 100);

            Assert.Null(user);

            _fixture.Dispose();
        }
        public void CanRegisterEmployerWithoutDescriptionTest()
        {
            IEmployerDAO <Employer> EmployerDAO = new EmployerDAO(_connection);
            Employer testEmployer = new Employer();

            testEmployer.FirstName = "Marcelo";
            testEmployer.LastName  = "Carvalho";
            testEmployer.UserName  = "******";
            testEmployer.Password  = "******";
            testEmployer.Email     = "*****@*****.**";
            testEmployer.Address   = "Lixa";

            Employer returned = EmployerDAO.Create(testEmployer);

            Assert.Equal(testEmployer.FirstName, returned.FirstName);
            Assert.Equal(testEmployer.LastName, returned.LastName);
            Assert.Equal(testEmployer.UserName, returned.UserName);
            Assert.Equal(testEmployer.Password, returned.Password);
            Assert.Equal(testEmployer.Email, returned.Email);
            Assert.Equal(testEmployer.Address, returned.Address);

            _fixture.Dispose();
        }