Esempio n. 1
0
        public void TestServerServiceCreateAccount()
        {
            var     userService            = new UserService();
            var     userConferenceService  = new UserConferenceService();
            var     adminConferenceService = new AdminConferenceService();
            var     proposalService        = new ProposalService();
            var     reviewService          = new ReviewService();
            var     ticketService          = new TicketService();
            var     enumService            = new EnumGetDataService();
            var     emailService           = new EmailService();
            var     sectionService         = new SectionService();
            var     serverService          = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService);
            UserDTO userToAdd = new UserDTO()
            {
                Username   = "******",
                Password   = "******",
                FirstName  = "User",
                LastName   = "ForTest",
                Email      = "*****@*****.**",
                WebPage    = "test.ro",
                Admin      = true,
                Validation = "Waiting"
            };

            Assert.AreEqual(0, serverService.findAll().ToList().Count);
            var userSaved = serverService.createAccount(userToAdd);

            Assert.AreEqual(1, serverService.findAll().ToList().Count);
            Assert.AreEqual("UserForTest", serverService.findUser(userSaved.Id).Username);
            Assert.AreEqual("test.ro", userSaved.WebPage);
        }
Esempio n. 2
0
        public void TestServerServiceFindUser()
        {
            PrepareData();
            var userService            = new UserService();
            var userConferenceService  = new UserConferenceService();
            var adminConferenceService = new AdminConferenceService();
            var proposalService        = new ProposalService();
            var reviewService          = new ReviewService();
            var ticketService          = new TicketService();
            var enumService            = new EnumGetDataService();
            var emailService           = new EmailService();
            var sectionService         = new SectionService();
            var serverService          = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService);

            var user1 = serverService.findUser(1);
            var user3 = serverService.findUser(3);

            Assert.AreEqual("User1", user1.Username);
            Assert.AreEqual("User3", user3.Username);
            Assert.AreEqual("Last1", user1.LastName);
            Assert.AreEqual("Last3", user3.LastName);
            Assert.AreEqual("First1", user1.FirstName);
            Assert.AreEqual("First3", user3.FirstName);
            Assert.AreEqual(true, user1.Admin);
            Assert.AreEqual(false, user3.Admin);
        }
Esempio n. 3
0
        public void TestServerServiceUpdateAccount()
        {
            var userService            = new UserService();
            var userConferenceService  = new UserConferenceService();
            var adminConferenceService = new AdminConferenceService();
            var proposalService        = new ProposalService();
            var reviewService          = new ReviewService();
            var ticketService          = new TicketService();
            var enumService            = new EnumGetDataService();
            var emailService           = new EmailService();
            var sectionService         = new SectionService();
            var serverService          = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService);

            PrepareData();


            Assert.AreEqual(4, serverService.findAll().ToList().Count);
            var userForUpdate = serverService.findUser(1);

            userForUpdate.FirstName = "Pop";
            userForUpdate.LastName  = "Mihai";
            userForUpdate.Username  = "******";

            var updatedUser      = serverService.updateAccount(userForUpdate);
            var userFromDataBase = serverService.findUser(updatedUser.Id);

            Assert.AreEqual(4, serverService.findAll().ToList().Count);
            Assert.AreEqual("Pop", updatedUser.FirstName);
            Assert.AreEqual("Mihai", updatedUser.LastName);
            Assert.AreEqual("Updated", updatedUser.Username);
            Assert.AreEqual("Pop", userFromDataBase.FirstName);
            Assert.AreEqual("Mihai", userFromDataBase.LastName);
            Assert.AreEqual("Updated", userForUpdate.Username);
        }
Esempio n. 4
0
        public void TestServerServiceFindAll()
        {
            var userService            = new UserService();
            var userConferenceService  = new UserConferenceService();
            var adminConferenceService = new AdminConferenceService();
            var proposalService        = new ProposalService();
            var reviewService          = new ReviewService();
            var ticketService          = new TicketService();
            var enumService            = new EnumGetDataService();
            var emailService           = new EmailService();
            var sectionService         = new SectionService();
            var serverService          = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService);

            Assert.AreEqual(0, serverService.findAll().ToList().Count);
            PrepareData();
            Assert.AreEqual(4, serverService.findAll().ToList().Count);
        }
Esempio n. 5
0
        public void TestServerServiceRemoveAccount()
        {
            var userService            = new UserService();
            var userConferenceService  = new UserConferenceService();
            var adminConferenceService = new AdminConferenceService();
            var proposalService        = new ProposalService();
            var reviewService          = new ReviewService();
            var ticketService          = new TicketService();
            var enumService            = new EnumGetDataService();
            var emailService           = new EmailService();
            var sectionService         = new SectionService();
            var serverService          = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService);

            PrepareData();
            var nrUsers     = serverService.findAll().ToList().Count;
            var userRemoved = serverService.removeAccount(1);

            Assert.AreEqual(nrUsers - 1, serverService.findAll().ToList().Count);
            Assert.IsNull(serverService.findUser(1));
            Assert.AreEqual("User1", userRemoved.Username);
            Assert.AreEqual(1, userRemoved.Id);
        }
Esempio n. 6
0
        public void TestServerServiceLogIn()
        {
            var userService            = new UserService();
            var userConferenceService  = new UserConferenceService();
            var adminConferenceService = new AdminConferenceService();
            var proposalService        = new ProposalService();
            var reviewService          = new ReviewService();
            var ticketService          = new TicketService();
            var enumService            = new EnumGetDataService();
            var emailService           = new EmailService();
            var sectionService         = new SectionService();
            var serverService          = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService);

            UserDTO userToAdd = new UserDTO()
            {
                Username  = "******",
                Password  = "******",
                FirstName = "User",
                LastName  = "ForTest",
                Email     = "*****@*****.**",
                WebPage   = "test.ro",
                Admin     = true,
            };

            //test duplicat, e acelasi lucru daca folosesc loginDin UserService sau serverService
            var userCreated = serverService.createAccount(userToAdd);

            //validare cont nou
            //todo: AdminUserCheckerService ar trebuii inlocuit cu un mock
            var adminUserCheckerService = new AdminUserCheckerService();
            var userAccepted            = adminUserCheckerService.AcceptNewUser(userCreated);

            var userReturnedFromLogin = serverService.logIn("UserForTest", "Password");

            //adminul face validarea in geneal, aici trebuie simulata activarea contului, altfel testul crapa

            Assert.AreEqual("UserForTest", userReturnedFromLogin.Username);
            Assert.IsNull(serverService.logIn("abcde", "1234"));
        }