public void CanSearchMateWithCategoriesAddressRankAndDistanceTest()
        {
            IMateDAO<Mate> MateDAO = new MateDAO(_connection);

            Mate firstMate = new Mate();

            firstMate.FirstName = "Marcelo";
            firstMate.LastName = "Carvalho";
            firstMate.UserName = "******";
            firstMate.Password = "******";
            firstMate.Email = "*****@*****.**";
            firstMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
            firstMate.Address = "Rua Eng. Luís Carneiro Leão, Figueiró";
            firstMate.Categories = new[] { Categories.CLEANING, Categories.ELECTRICITY };
            firstMate.Rank = Ranks.MATE;
            firstMate.Range = 50;

            Mate returnedFirst = MateDAO.Create(firstMate);

            Mate secondMate = new Mate();

            secondMate.FirstName = "Samuel";
            secondMate.LastName = "Cunha";
            secondMate.UserName = "******";
            secondMate.Password = "******";
            secondMate.Email = "*****@*****.**";
            secondMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
            secondMate.Address = "Vila Nova de Gaia";
            secondMate.Categories = new[] { Categories.GARDENING, Categories.FURNITURE_ASSEMBLE };
            secondMate.Rank = Ranks.SUPER_MATE;
            secondMate.Range = 20;

            Mate returnedSecond = MateDAO.Create(secondMate);

            Categories[] categories = { Categories.CLEANING, Categories.GARDENING };
            string myAddress = "Rua de Salgueiros, Penafiel";

            List<Mate> mates = MateDAO.GetMates(categories, myAddress, Ranks.MATE, 40, null);

            Mate[] matesArray = mates.ToArray();

            Assert.Equal(returnedFirst.FirstName, matesArray[0].FirstName);
            Assert.Equal(returnedFirst.LastName, matesArray[0].LastName);
            Assert.Equal(returnedFirst.UserName, matesArray[0].UserName);
            Assert.Equal(returnedFirst.Email, matesArray[0].Email);
            Assert.Equal(returnedFirst.Description, matesArray[0].Description);
            Assert.Equal(returnedFirst.Address, matesArray[0].Address);
            Array.Reverse(matesArray[0].Categories);
            Assert.Equal(returnedFirst.Categories, matesArray[0].Categories);
            Assert.Equal(returnedFirst.Rank, matesArray[0].Rank);
            Assert.Equal(returnedFirst.Range, matesArray[0].Range);

            Assert.Single(matesArray);

            _fixture.Dispose();
        }
        public void CanMateAddCategoriesTest()
        {
            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          returned = MateDAO.Create(testMate);
            CategoryModel category = new CategoryModel();

            category.categories = Categories.CLEANING;
            CategoryModel[] categories = { category };

            MateDAO.AddCategory(returned.Id, categories);

            Assert.True(MateDAO.CategoriesList(returned.Id).ToList().Exists(a => a.categories == Categories.CLEANING));

            _fixture.Dispose();
        }
Exemple #3
0
        public void CanUserUpdatePasswordTest()
        {
            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 returned = MateDAO.Create(testMate);

            UserDAO             userDAO = new UserDAO(_connection);
            PasswordUpdateModel newPass = new PasswordUpdateModel();

            newPass.Password    = "******";
            newPass.OldPassword = "******";

            Assert.True(userDAO.UpdatePassword(newPass, returned.Id));

            _fixture.Dispose();
        }
Exemple #4
0
        public void CanRegisterMateTest()
        {
            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);

            Assert.Equal(testMate.FirstName, returned.FirstName);
            Assert.Equal(testMate.LastName, returned.LastName);
            Assert.Equal(testMate.UserName, returned.UserName);
            Assert.Equal(testMate.Password, returned.Password);
            Assert.Equal(testMate.Email, returned.Email);
            Assert.Equal(testMate.Description, returned.Description);
            Assert.Equal(testMate.Address, returned.Address);
            Assert.Equal(testMate.Categories, returned.Categories);
            Assert.Equal(testMate.Rank, returned.Rank);
            Assert.Equal(testMate.Range, returned.Range);

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

            string          refreshToken    = RefreshTokenHelper.generateRefreshToken();
            RefreshTokenDAO refreshTokenDAO = new RefreshTokenDAO(_connection);

            Assert.Throws <Exception>(() => refreshTokenDAO.saveEncryptedRefreshToken(refreshToken, "*****@*****.**"));

            _fixture.Dispose();
        }
Exemple #6
0
        public void CanMateListWorkCategoriesTest()
        {
            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);

            List <CategoryModel> category = MateDAO.CategoriesList(returned.Id).ToList();

            Assert.Equal(Categories.PLUMBING, category.ElementAt(0).categories);
            Assert.Equal(Categories.CLEANING, category.ElementAt(1).categories);

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

            string          refreshToken    = RefreshTokenHelper.generateRefreshToken();
            RefreshTokenDAO refreshTokenDAO = new RefreshTokenDAO(_connection);

            refreshTokenDAO.saveEncryptedRefreshToken(refreshToken, returned.Email);

            EncryptedRefreshTokenModel returnedToken = refreshTokenDAO.GetEncryptedRefreshTokenModel(returned.Email);

            Assert.Equal(returned.Email, returnedToken.Email);
            Assert.True(PasswordOperations.VerifyHash(refreshToken, returnedToken.Hash, returnedToken.Salt));

            _fixture.Dispose();
        }
Exemple #8
0
        public void CanRegisterMateWithoutDescriptionTest()
        {
            IMateDAO <Mate> MateDAO  = new MateDAO(_connection);
            Mate            testMate = new Mate();

            testMate.FirstName  = "Miguel";
            testMate.LastName   = "Dev";
            testMate.UserName   = "******";
            testMate.Password   = "******";
            testMate.Email      = "*****@*****.**";
            testMate.Address    = "Figueiró";
            testMate.Categories = new[] { Categories.CLEANING, Categories.PLUMBING };
            testMate.Rank       = Ranks.SUPER_MATE;
            testMate.Range      = 20;

            Mate returned = MateDAO.Create(testMate);

            Assert.Equal(testMate.FirstName, returned.FirstName);
            Assert.Equal(testMate.LastName, returned.LastName);
            Assert.Equal(testMate.UserName, returned.UserName);
            Assert.Equal(testMate.Password, returned.Password);
            Assert.Equal(testMate.Email, returned.Email);
            Assert.Equal(testMate.Address, returned.Address);
            Assert.Equal(testMate.Categories, returned.Categories);
            Assert.Equal(testMate.Rank, returned.Rank);
            Assert.Equal(testMate.Range, returned.Range);

            _fixture.Dispose();
        }
Exemple #9
0
        public void CanGetMateWithoutDescriptionByIdTest()
        {
            IMateDAO <Mate> MateDAO  = new MateDAO(_connection);
            Mate            testMate = new Mate();

            testMate.FirstName  = "Jessica";
            testMate.LastName   = "Coelho";
            testMate.UserName   = "******";
            testMate.Password   = "******";
            testMate.Email      = "*****@*****.**";
            testMate.Address    = "Ordem";
            testMate.Categories = new[] { Categories.FURNITURE_ASSEMBLE, Categories.TRANSPORTATION };
            testMate.Rank       = Ranks.MATE;
            testMate.Range      = 20;

            Mate returnedMate = MateDAO.Create(testMate);

            Mate m = MateDAO.FindMateById(returnedMate.Id);

            Assert.Equal(returnedMate.Id, m.Id);
            Assert.Equal(returnedMate.UserName, m.UserName);
            Assert.Equal(returnedMate.FirstName, m.FirstName);
            Assert.Equal(returnedMate.LastName, m.LastName);
            Assert.Equal(returnedMate.Email, m.Email);
            Assert.Equal(returnedMate.Address, m.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();
        }
Exemple #11
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();
        }
Exemple #12
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();
        }
Exemple #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();
        }
Exemple #15
0
 public ActionResult <MateModel> Create(MateRegister regMate)
 {
     try
     {
         Mate            mate      = _mapper.Map <Mate>(regMate);
         IMateDAO <Mate> MateDAO   = new MateDAO(_connection);
         MateModel       mateModel = _mapper.Map <MateModel>(MateDAO.Create(mate));
         return(Ok(mateModel));
     }
     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();
        }
        public void CanUserRecoverPasswordTest()
        {
            IMateDAO <Mate> MateDAO  = new MateDAO(_connection);
            Mate            testMate = new Mate();

            testMate.FirstName   = "Samuel";
            testMate.LastName    = "Cunha";
            testMate.UserName    = "******";
            testMate.Password    = "******";
            testMate.Email       = "*****@*****.**";
            testMate.Description = "Quero recuperar a pass";
            testMate.Address     = "Aparecida";
            testMate.Categories  = new[] { Categories.GARDENING };
            testMate.Rank        = Ranks.MATE;
            testMate.Range       = 10;

            Mate returned = MateDAO.Create(testMate);

            var tokenHandler    = new JwtSecurityTokenHandler();
            var key             = Encoding.ASCII.GetBytes("RQj!O9+Sq|D8XjYa|}kgnk|}ZaQUso)EMF48Fx1~0n~^~%]n|O{NqH(&5RqXbx7");
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(new Claim[]
                {
                    new Claim(ClaimTypes.Email, testMate.Email.ToString())
                }),
                Expires            = DateTime.UtcNow.AddMinutes(10),
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
            };

            var    token         = tokenHandler.CreateToken(tokenDescriptor);
            var    tokenString   = tokenHandler.WriteToken(token);
            String auxResetToken = tokenString;

            PasswordOperations.NewPasswordRequest("*****@*****.**", auxResetToken);

            LoginDAO             loginDAO        = new LoginDAO(_connection);
            RecoverPasswordModel recoverPassword = new RecoverPasswordModel();

            recoverPassword.Email           = "*****@*****.**";
            recoverPassword.Password        = "******";
            recoverPassword.ConfirmPassword = "******";
            recoverPassword.Token           = tokenString;

            Assert.True(loginDAO.RecoverPassword(recoverPassword, returned.Email));

            _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();
        }
        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 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();
        }
        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 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 CanRegisterMateWrongPasswordTest()
        {
            IMateDAO <Mate> MateDAO  = new MateDAO(_connection);
            Mate            testMate = new Mate();
            string          password = testMate.Password;

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

            Assert.False(PasswordOperations.VerifyHash("12345", returned.Password, returned.PasswordSalt));

            _fixture.Dispose();
        }
        public void CanMateUpdateProfileTest()
        {
            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 returned = MateDAO.Create(testMate);

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

            Mate updated = MateDAO.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);
            Assert.Equal(returned.Range, updated.Range);

            _fixture.Dispose();
        }
Exemple #26
0
        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 CanSearchJobPostWithRatingAndCategoryTest()
        {
            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);

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

            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, 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.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 CanGetChatsTest()
        {
            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();
            int chatId2 = chatDao.CreateChatId();

            Chat chat = new Chat();

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

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

            Chat chat2 = new Chat();

            chat2.UserId = returned.Id;
            chat2.ChatId = chatId2;

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

            Chat[] user1ChatArray = chatDao.GetChats(returned.Id);
            Chat[] user2ChatArray = chatDao.GetChats(returnedMate.Id);

            Assert.Equal(2, user1ChatArray.Length);
            Assert.Equal(2, user2ChatArray.Length);

            Assert.Equal(chatId, user1ChatArray[0].ChatId);
            Assert.Equal(returnedMate.Id, user1ChatArray[0].UserId);
            Assert.Equal(chatId, user2ChatArray[0].ChatId);
            Assert.Equal(returned.Id, user2ChatArray[0].UserId);

            Assert.Equal(chatId2, user1ChatArray[1].ChatId);
            Assert.Equal(returnedMate.Id, user1ChatArray[1].UserId);
            Assert.Equal(chatId2, user2ChatArray[1].ChatId);
            Assert.Equal(returned.Id, user2ChatArray[1].UserId);

            _fixture.Dispose();
        }
        public void CanAddMessageTest()
        {
            IEmployerDAO <Employer> employerDAO = new EmployerDAO(_connection);
            Employer testEmployerC = new Employer();

            testEmployerC.FirstName   = "Ema";
            testEmployerC.LastName    = "Coelho";
            testEmployerC.UserName    = "******";
            testEmployerC.Password    = "******";
            testEmployerC.Email       = "*****@*****.**";
            testEmployerC.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
            testEmployerC.Address     = "Lousada";

            // Employe a utilizar
            Employer returnedEmployer = employerDAO.Create(testEmployerC);

            IMateDAO <Mate> MateDAO = new MateDAO(_connection);

            Mate firstMate = new Mate();

            firstMate.FirstName   = "Marcelddo";
            firstMate.LastName    = "Carvalho";
            firstMate.UserName    = "******";
            firstMate.Password    = "******";
            firstMate.Email       = "*****@*****.**";
            firstMate.Description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
            firstMate.Address     = "Sra. Aparecida, Lousada";
            firstMate.Categories  = new[] { Categories.CLEANING, Categories.ELECTRICITY };
            firstMate.Rank        = Ranks.MATE;
            firstMate.Range       = 50;


            Mate returnMate = MateDAO.Create(firstMate);

            ChatDAO chatDAO = new ChatDAO(_connection);

            chatDAO.AddChatHubConnection(returnedEmployer.Id, "connection1");
            chatDAO.AddChatHubConnection(returnMate.Id, "connection2");

            int chatId = chatDAO.CreateChatId();

            Chat chat = new Chat();

            chat.ChatId = chatId;
            chat.UserId = returnedEmployer.Id;
            chatDAO.CreateChat(chat);
            chat.UserId = returnMate.Id;
            chatDAO.CreateChat(chat);


            ChatConnection connect1 = chatDAO.GetChatConnectionFromUserId(returnedEmployer.Id);
            ChatConnection connect2 = chatDAO.GetChatConnectionFromUserId(returnMate.Id);

            String MessageSend  = "message test";
            String MessageSend2 = "message test 2";

            bool addedToDb1 = chatDAO.AddMessage(connect1.Connection, connect2.Connection, MessageSend, DateTime.Now, returnedEmployer.Id);
            bool addedToDb2 = chatDAO.AddMessage(connect2.Connection, connect1.Connection, MessageSend2, DateTime.Now, returnMate.Id);

            Assert.True(addedToDb1);
            Assert.True(addedToDb2);

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

            MateReview reviewsTest = new MateReview();

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

            MateReview reviewsTest2 = new MateReview();

            reviewsTest2.Rating  = 2;
            reviewsTest2.Comment = "O trolha fez um trabalho mau!";

            IReviewMateDAO ReviewMateDAO   = new ReviewMateDAO(_connection);
            MateReview     returnedReview1 = ReviewMateDAO.ReviewMate(returnedEmp.Id, returned.Id, reviewsTest);
            MateReview     returnedReview2 = ReviewMateDAO.ReviewMate(returnedEmp.Id, returned.Id, reviewsTest2);

            List <MateReviewsModel> ReviewsList = ReviewMateDAO.MateReviewsList(returned.Id);

            MateReviewsModel[] array = ReviewsList.ToArray();

            Assert.Equal(2, array.Length);

            Assert.Equal(reviewsTest.Rating, array[0].Rating);
            Assert.Equal(reviewsTest.Comment, array[0].Comment);
            Assert.Equal(returnedEmp.UserName, array[0].Author);

            Assert.Equal(reviewsTest2.Rating, array[1].Rating);
            Assert.Equal(reviewsTest2.Comment, array[1].Comment);
            Assert.Equal(returnedEmp.UserName, array[1].Author);

            _fixture.Dispose();
        }