Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo n.º 5
0
        public void TestConferenceServiceAddConf()
        {
            var           service         = new UserConferenceService();
            ConferenceDTO conferenceToAdd = new ConferenceDTO
            {
                Name              = "Nume",
                Edition           = 11,
                StartDate         = (new DateTime(2018, 1, 12)).ToString(),
                EndDate           = (new DateTime(2020, 1, 12)).ToString(),
                Domain            = "Domeniu",
                AbstractDeadline  = (new DateTime(2019, 1, 12)).ToString(),
                FullPaperDeadline = (new DateTime(2020, 1, 1)).ToString(),
                MainDescription   = "Descriere",
                Price             = 25f,
                State             = ConferenceState.Accepted.ToString()
            };

            Assert.AreEqual(0, service.GetAllConferences().ToList().Count);
            PrepareData();
            Assert.AreEqual(1, service.GetAllConferences().ToList().Count);

            //the conference will be added
            try
            {
                var confSaved = service.AddConference(1, conferenceToAdd);
                Assert.AreEqual(2, service.GetAllConferences().ToList().Count);
            }
            catch (Exception e)
            {
                Assert.Fail();
            }

            //an error is thrown when the conference fails validation
            try
            {
                service.AddConference(1, conferenceToAdd);
                Assert.Fail();
            }
            catch (Exception e)
            {
                Assert.IsNotNull(e);
                Assert.AreEqual(2, service.GetAllConferences().ToList().Count);
            }
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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"));
        }