Exemplo n.º 1
0
        public void User_Authorized_When_Position_Belongs_To_User_Jobsearch()
        {
            // Setup
            var user     = new User();
            var position = new Position {
                Company = new Company {
                    JobSearch = new JobSearch {
                        User = user
                    }
                }
            };

            _context.Positions.Add(position);
            _context.SaveChanges();

            IProcess <PositionAuthorizationParams, AuthorizationResultViewModel> process = new AuthorizationProcesses(_context);

            // Act
            AuthorizationResultViewModel result = process.Execute(new PositionAuthorizationParams
            {
                PositionId       = position.Id,
                RequestingUserId = user.Id
            });

            // Verify
            Assert.IsNotNull(result, "Result was null");
            Assert.IsTrue(result.UserAuthorized, "User was not authorized");
        }
Exemplo n.º 2
0
        public void User_Authorized_When_Contact_Belongs_To_User_Jobsearch()
        {
            // Setup
            var user   = new User();
            var search = new JobSearch {
                User = user
            };
            var company = new Company {
                JobSearch = search
            };
            var contact = new Contact {
                Company = company
            };

            _context.Contacts.Add(contact);
            _context.SaveChanges();

            IProcess <ContactAutorizationParams, AuthorizationResultViewModel> process = new AuthorizationProcesses(_context);

            // Act
            AuthorizationResultViewModel result = process.Execute(new ContactAutorizationParams
            {
                ContactId        = contact.Id,
                RequestingUserId = user.Id
            });

            // Verify
            Assert.IsNotNull(result, "Result was null");
            Assert.IsTrue(result.UserAuthorized, "User was not authorized");
        }
        public void User_Not_Authorized_When_Company__Doesnt_Belong_To_User_Jobsearch()
        {
            // Setup
            var user   = new User();
            var user2  = new User();
            var search = new JobSearch {
                User = user
            };
            var company = new Company {
                JobSearch = search
            };
            var company2 = new Company {
                JobSearch = new JobSearch {
                    User = user2
                }
            };

            _context.Companies.Add(company);
            _context.Users.Add(user2);
            _context.SaveChanges();

            IProcess <CompanyQueryAuthorizationParams, AuthorizationResultViewModel> process = new AuthorizationProcesses(_context);

            // Act
            AuthorizationResultViewModel result = process.Execute(new CompanyQueryAuthorizationParams
            {
                CompanyId        = company.Id,
                RequestingUserId = user2.Id
            });

            // Verify
            Assert.IsNotNull(result, "Result was null");
            Assert.IsFalse(result.UserAuthorized, "User was incorrectly authorized");
        }
Exemplo n.º 4
0
        public void User_Not_Authorized_When_Task__Doesnt_Belong_To_User_Jobsearch()
        {
            // Setup
            var user  = new User();
            var user2 = new User();
            var task  = new Task {
                Company = new Company {
                    JobSearch = new JobSearch {
                        User = user
                    }
                }
            };
            var task2 = new Task {
                Company = new Company {
                    JobSearch = new JobSearch {
                        User = user2
                    }
                }
            };

            _context.Tasks.Add(task);
            _context.Tasks.Add(task2);
            _context.SaveChanges();

            IProcess <TaskAuthorizationParams, AuthorizationResultViewModel> process = new AuthorizationProcesses(_context);

            // Act
            AuthorizationResultViewModel result = process.Execute(new TaskAuthorizationParams
            {
                TaskId           = task.Id,
                RequestingUserId = user2.Id
            });

            // Verify
            Assert.IsNotNull(result, "Result was null");
            Assert.IsFalse(result.UserAuthorized, "User was incorrectly authorized");
        }