Ejemplo n.º 1
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();
        }