Example #1
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();
        }
        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();
        }
Example #3
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 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 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();
        }