예제 #1
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 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();
        }
예제 #3
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();
        }
예제 #4
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();
        }
예제 #5
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 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();
        }
예제 #7
0
        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();
        }