public DeleteUserController(
     IDeleteUserService deleteUserService,
     IGetUserService getUserService)
 {
     _deleteUserService = deleteUserService;
     _getUserService    = getUserService;
 }
예제 #2
0
        public TechnicalAdvisorServiceTests()
        {
            _loggerAdapter = Substitute.For <ILoggerAdapter>();
            _nyssContext   = Substitute.For <INyssContext>();
            _identityUserRegistrationServiceMock = Substitute.For <IIdentityUserRegistrationService>();
            _verificationEmailServiceMock        = Substitute.For <IVerificationEmailService>();
            _nationalSocietyUserService          = Substitute.For <INationalSocietyUserService>();
            _deleteUserService = Substitute.For <IDeleteUserService>();

            var applicationLanguages      = new List <ApplicationLanguage>();
            var applicationLanguagesDbSet = applicationLanguages.AsQueryable().BuildMockDbSet();

            _nyssContext.ApplicationLanguages.Returns(applicationLanguagesDbSet);

            _technicalAdvisorService = new TechnicalAdvisorService(_identityUserRegistrationServiceMock, _nationalSocietyUserService, _nyssContext, _loggerAdapter, _verificationEmailServiceMock,
                                                                   _deleteUserService);

            _identityUserRegistrationServiceMock.CreateIdentityUser(Arg.Any <string>(), Arg.Any <Role>()).Returns(ci => new IdentityUser
            {
                Id    = "123",
                Email = (string)ci[0]
            });

            SetupTestNationalSocieties();
        }
예제 #3
0
        public NationalSocietyUserServiceTests()
        {
            _loggerAdapter = Substitute.For <ILoggerAdapter>();
            _identityUserRegistrationService = Substitute.For <IIdentityUserRegistrationService>();
            _nyssContext       = Substitute.For <INyssContext>();
            _deleteUserService = Substitute.For <IDeleteUserService>();
            SetupTestNationalSociety();

            _nationalSocietyUserService = new NationalSocietyUserService(_nyssContext, _loggerAdapter, _identityUserRegistrationService, _deleteUserService);
        }
예제 #4
0
 public TechnicalAdvisorService(IIdentityUserRegistrationService identityUserRegistrationService, INationalSocietyUserService nationalSocietyUserService, INyssContext dataContext,
                                ILoggerAdapter loggerAdapter, IVerificationEmailService verificationEmailService, IDeleteUserService deleteUserService)
 {
     _identityUserRegistrationService = identityUserRegistrationService;
     _dataContext   = dataContext;
     _loggerAdapter = loggerAdapter;
     _nationalSocietyUserService = nationalSocietyUserService;
     _verificationEmailService   = verificationEmailService;
     _deleteUserService          = deleteUserService;
 }
예제 #5
0
 public GlobalCoordinatorService(
     IIdentityUserRegistrationService identityUserRegistrationService,
     INyssContext dataContext,
     ILoggerAdapter loggerAdapter, IVerificationEmailService verificationEmailService, IDeleteUserService deleteUserService)
 {
     _identityUserRegistrationService = identityUserRegistrationService;
     _dataContext              = dataContext;
     _loggerAdapter            = loggerAdapter;
     _verificationEmailService = verificationEmailService;
     _deleteUserService        = deleteUserService;
 }
예제 #6
0
 public UserController(
     IAddUserService addUserService,
     IUpdateUserService updateUserService,
     IDeleteUserService deleteUserService,
     IGetUserService getUserService)
 {
     _addUserService    = addUserService;
     _updateUserService = updateUserService;
     _deleteUserService = deleteUserService;
     _getUserService    = getUserService;
 }
예제 #7
0
 public UserServices(IUserRepository userRepository, IGetAllUsersService getAllUsersService,
                     IGetUserByIdService getUserByIdService, ICreateUserService createUserService,
                     IGetUserByEmailService getUserByEmailService, IDeleteUserService deleteUserService)
 {
     this.userRepository        = userRepository;
     this.getAllUsersService    = getAllUsersService;
     this.getUserByIdService    = getUserByIdService;
     this.createUserService     = createUserService;
     this.getUserByEmailService = getUserByEmailService;
     this.deleteUserService     = deleteUserService;
 }
예제 #8
0
 // GET: UserController
 public UserController(IGetUsersService getUsersService, IGetRolesService getRolesService,
                       IRegisterUserService registerUserService, IDeleteUserService deleteUserService,
                       IUserStatusChangeService userStatusChangeService, IEditUserService editUserService)
 {
     _getUsersService         = getUsersService;
     _getRolesService         = getRolesService;
     _registerUserService     = registerUserService;
     _deleteUserService       = deleteUserService;
     _userStatusChangeService = userStatusChangeService;
     _edituserservice         = editUserService;
 }
예제 #9
0
 public UserController(ICreateUserService createUserService, IGetUsersService getUsersService,
                       IUpdateUserService updateUserService, IChangePasswordService changePasswordService,
                       IGetRolesService getRolesService, IDeleteUserService deleteUserService,
                       IGetPermissionsService getPermissionsService, IPermissionVerificationService permissionVerificationService)
 {
     this.createUserService             = createUserService;
     this.getUsersService               = getUsersService;
     this.updateUserService             = updateUserService;
     this.changePasswordService         = changePasswordService;
     this.getRolesService               = getRolesService;
     this.deleteUserService             = deleteUserService;
     this.getPermissionsService         = getPermissionsService;
     this.permissionVerificationService = permissionVerificationService;
 }
예제 #10
0
 public void Initialize()
 {
     _dataFactory       = MockRepository.GenerateStub <IDataFactory>();
     _uow               = MockRepository.GenerateStub <IUnitOfWork>();
     _userRepository    = MockRepository.GenerateStub <IUserRepository>();
     _addUserRule       = MockRepository.GenerateStub <IAddUserRule>();
     _addUserLogic      = MockRepository.GenerateStub <IAddUserLogic>();
     _addUserService    = MockRepository.GenerateStub <IAddUserService>();
     _getUserLogic      = MockRepository.GenerateStub <IGetUserLogic>();
     _getUserService    = MockRepository.GenerateStub <IGetUserService>();
     _updateUserRule    = MockRepository.GenerateStub <IUpdateUserRule>();
     _updateUserLogic   = MockRepository.GenerateStub <IUpdateUserLogic>();
     _updateUserService = MockRepository.GenerateStub <IUpdateUserService>();
     _deleteUserLogic   = MockRepository.GenerateStub <IDeleteUserLogic>();
     _deleteUserService = MockRepository.GenerateStub <IDeleteUserService>();
 }
예제 #11
0
 public void Initialize()
 {
     _dataFactory       = new DataFactory();
     _uow               = new UnitOfWork(_dataFactory);
     _userRepository    = new UserRepository(_dataFactory);
     _addUserRule       = new AddUserRule();
     _addUserLogic      = new AddUserLogic(_addUserRule);
     _addUserService    = new AddUserService(_uow, _userRepository, _addUserLogic);
     _getUserLogic      = new GetUserLogic();
     _getUserService    = new GetUserService(_userRepository, _getUserLogic);
     _updateUserRule    = new UpdateUserRule();
     _updateUserLogic   = new UpdateUserLogic(_updateUserRule, _getUserLogic);
     _updateUserService = new UpdateUserService(_uow, _userRepository, _updateUserLogic);
     _deleteUserLogic   = new DeleteUserLogic(_getUserLogic);
     _deleteUserService = new DeleteUserService(_uow, _userRepository, _deleteUserLogic);
 }
예제 #12
0
        public GlobalCoordinatorServiceTests()
        {
            _loggerAdapter = Substitute.For <ILoggerAdapter>();
            _nyssContext   = Substitute.For <INyssContext>();
            _identityUserRegistrationServiceMock = Substitute.For <IIdentityUserRegistrationService>();
            _verificationEmailServiceMock        = Substitute.For <IVerificationEmailService>();
            _deleteUserService = Substitute.For <IDeleteUserService>();

            _globalCoordinatorService =
                new GlobalCoordinatorService(_identityUserRegistrationServiceMock, _nyssContext, _loggerAdapter, _verificationEmailServiceMock, _deleteUserService);

            _identityUserRegistrationServiceMock.CreateIdentityUser(Arg.Any <string>(), Arg.Any <Role>()).Returns(ci => new IdentityUser
            {
                Id    = "123",
                Email = (string)ci[0]
            });

            ArrangeApplicationLanguages();
        }
예제 #13
0
        public DataConsumerServiceTests()
        {
            _loggerAdapter = Substitute.For <ILoggerAdapter>();
            _nyssContext   = Substitute.For <INyssContext>();
            _identityUserRegistrationServiceMock = Substitute.For <IIdentityUserRegistrationService>();
            _verificationEmailServiceMock        = Substitute.For <IVerificationEmailService>();
            _nationalSocietyUserService          = Substitute.For <INationalSocietyUserService>();
            _deleteUserService = Substitute.For <IDeleteUserService>();

            _dataConsumerService = new DataConsumerService(_identityUserRegistrationServiceMock, _nationalSocietyUserService, _nyssContext, _loggerAdapter, _verificationEmailServiceMock,
                                                           _deleteUserService);

            _identityUserRegistrationServiceMock.CreateIdentityUser(Arg.Any <string>(), Arg.Any <Role>()).Returns(ci => new IdentityUser
            {
                Id    = "123",
                Email = (string)ci[0]
            });

            SetupTestNationalSocieties();
        }
예제 #14
0
 public UserController(
     SiteSettings siteSettings,
     IAddUserRoleRelationService addUserRoleRelationService,
     IAddUserService addUserService,
     IDeleteUserRoleRelationService deleteUserRoleRelationService,
     IDeleteUserService deleteUserService,
     IFindUserService findUserService,
     IGetApplicationsService getApplicationsService,
     IGetRolesService getRolesService,
     IGetUsersService getUsersService,
     IUpdateUserService updateUserService)
 {
     _siteSettings = siteSettings;
     _addUserRoleRelationService    = addUserRoleRelationService;
     _addUserService                = addUserService;
     _deleteUserRoleRelationService = deleteUserRoleRelationService;
     _deleteUserService             = deleteUserService;
     _findUserService               = findUserService;
     _getApplicationsService        = getApplicationsService;
     _getRolesService               = getRolesService;
     _getUsersService               = getUsersService;
     _updateUserService             = updateUserService;
 }
예제 #15
0
        public ManagerServiceTests()
        {
            _loggerAdapter = Substitute.For <ILoggerAdapter>();
            _nyssContext   = Substitute.For <INyssContext>();
            _identityUserRegistrationServiceMock = Substitute.For <IIdentityUserRegistrationService>();
            _verificationEmailServiceMock        = Substitute.For <IVerificationEmailService>();
            _nationalSocietyUserService          = Substitute.For <INationalSocietyUserService>();
            _deleteUserService = Substitute.For <IDeleteUserService>();

            _managerService = new ManagerService(_identityUserRegistrationServiceMock, _nationalSocietyUserService, _nyssContext, _loggerAdapter, _verificationEmailServiceMock, _deleteUserService);


            var nationalSocieties = new List <NationalSociety>
            {
                new NationalSociety
                {
                    Id   = _nationalSocietyId,
                    Name = "Test national society"
                }
            };
            var applicationLanguages = new List <ApplicationLanguage>();
            var users = new List <User>
            {
                new AdministratorUser
                {
                    Id   = _administratorId,
                    Role = Role.Administrator
                },
                new ManagerUser
                {
                    Id                    = _managerId,
                    Role                  = Role.Manager,
                    EmailAddress          = "*****@*****.**",
                    Name                  = "*****@*****.**",
                    Organization          = "org org",
                    PhoneNumber           = "123",
                    AdditionalPhoneNumber = "321"
                }
            };
            var userNationalSocieties = new List <UserNationalSociety>
            {
                new UserNationalSociety
                {
                    User              = users[1],
                    UserId            = _managerId,
                    NationalSocietyId = _nationalSocietyId,
                    NationalSociety   = nationalSocieties[0]
                }
            };

            users[1].UserNationalSocieties = new List <UserNationalSociety> {
                userNationalSocieties[0]
            };

            var applicationLanguagesDbSet = applicationLanguages.AsQueryable().BuildMockDbSet();
            var usersDbSet                 = users.AsQueryable().BuildMockDbSet();
            var nationalSocietiesDbSet     = nationalSocieties.AsQueryable().BuildMockDbSet();
            var userNationalSocietiesDbSet = userNationalSocieties.AsQueryable().BuildMockDbSet();

            _nyssContext.ApplicationLanguages.Returns(applicationLanguagesDbSet);
            _nyssContext.Users.Returns(usersDbSet);
            _nyssContext.NationalSocieties.Returns(nationalSocietiesDbSet);
            _nyssContext.UserNationalSocieties.Returns(userNationalSocietiesDbSet);

            _identityUserRegistrationServiceMock.CreateIdentityUser(Arg.Any <string>(), Arg.Any <Role>()).Returns(ci => new IdentityUser
            {
                Id    = "123",
                Email = (string)ci[0]
            });
            _nyssContext.NationalSocieties.FindAsync(1).Returns(nationalSocieties[0]);

            _nationalSocietyUserService.GetNationalSocietyUser <ManagerUser>(Arg.Any <int>()).Returns(ci =>
            {
                var user = users.OfType <ManagerUser>().FirstOrDefault(x => x.Id == (int)ci[0]);
                if (user == null)
                {
                    throw new ResultException(ResultKey.User.Registration.UserNotFound);
                }

                return(user);
            });

            _nationalSocietyUserService.GetNationalSocietyUserIncludingNationalSocieties <ManagerUser>(Arg.Any <int>())
            .Returns(ci => _nationalSocietyUserService.GetNationalSocietyUser <ManagerUser>((int)ci[0]));
        }
예제 #16
0
        public SupervisorServiceTests()
        {
            _loggerAdapter = Substitute.For <ILoggerAdapter>();
            _nyssContext   = Substitute.For <INyssContext>();
            _identityUserRegistrationServiceMock = Substitute.For <IIdentityUserRegistrationService>();
            _verificationEmailServiceMock        = Substitute.For <IVerificationEmailService>();
            _nationalSocietyUserService          = Substitute.For <INationalSocietyUserService>();
            _deleteUserService = Substitute.For <IDeleteUserService>();
            var dateTimeProvider          = Substitute.For <IDateTimeProvider>();
            var applicationLanguages      = new List <ApplicationLanguage>();
            var applicationLanguagesDbSet = applicationLanguages.AsQueryable().BuildMockDbSet();

            _nyssContext.ApplicationLanguages.Returns(applicationLanguagesDbSet);

            _supervisorService = new SupervisorService(_identityUserRegistrationServiceMock, _nationalSocietyUserService, _nyssContext, _loggerAdapter, _verificationEmailServiceMock,
                                                       _deleteUserService, dateTimeProvider);

            _identityUserRegistrationServiceMock.CreateIdentityUser(Arg.Any <string>(), Arg.Any <Role>()).Returns(ci => new IdentityUser
            {
                Id    = "123",
                Email = (string)ci[0]
            });


            var nationalSocieties = new List <NationalSociety>
            {
                new NationalSociety
                {
                    Id   = _nationalSocietyId1,
                    Name = "Test national society 1"
                },
                new NationalSociety
                {
                    Id   = _nationalSocietyId2,
                    Name = "Test national society 2"
                }
            };

            var projects = new List <Project>
            {
                new Project
                {
                    Id = _projectId1,
                    NationalSociety = nationalSocieties[0],
                    Name            = "project 1",
                    State           = ProjectState.Open
                },
                new Project
                {
                    Id = _projectId2,
                    NationalSociety = nationalSocieties[0],
                    Name            = "project 2",
                    State           = ProjectState.Open
                },
                new Project
                {
                    Id = _projectId3,
                    NationalSociety = nationalSocieties[0],
                    Name            = "project 3",
                    State           = ProjectState.Closed
                },
                new Project
                {
                    Id = _projectId4,
                    NationalSociety = nationalSocieties[1],
                    Name            = "project 4",
                    State           = ProjectState.Open
                },
                new Project
                {
                    Id = _projectId5,
                    NationalSociety = nationalSocieties[1],
                    Name            = "project 5",
                    State           = ProjectState.Open
                }
            };

            var users = new List <User>
            {
                new AdministratorUser
                {
                    Id   = _administratorId,
                    Role = Role.Administrator
                },
                new SupervisorUser
                {
                    Id                    = _supervisorWithDataCollectorsId,
                    Role                  = Role.Supervisor,
                    EmailAddress          = "*****@*****.**",
                    Name                  = "*****@*****.**",
                    PhoneNumber           = "123",
                    AdditionalPhoneNumber = "321",
                    Sex                   = Sex.Male,
                    DecadeOfBirth         = 1990
                },
                new SupervisorUser
                {
                    Id                    = _supervisorWithoutDataCollectorsId,
                    Role                  = Role.Supervisor,
                    EmailAddress          = "*****@*****.**",
                    Name                  = "*****@*****.**",
                    PhoneNumber           = "123456",
                    AdditionalPhoneNumber = "321",
                    Sex                   = Sex.Male,
                    DecadeOfBirth         = 1990
                },
                new SupervisorUser
                {
                    Id                    = _supervisorWithDeletedDataCollectorsId,
                    Role                  = Role.Supervisor,
                    EmailAddress          = "*****@*****.**",
                    Name                  = "*****@*****.**",
                    PhoneNumber           = "123456",
                    AdditionalPhoneNumber = "321",
                    Sex                   = Sex.Male,
                    DecadeOfBirth         = 1990
                }
            };

            var supervisorWithDataCollectors        = (SupervisorUser)users[1];
            var supervisorWithoutDataCollectors     = (SupervisorUser)users[2];
            var supervisorWithDeletedDataCollectors = (SupervisorUser)users[3];
            var supervisorUserProjects = new List <SupervisorUserProject>
            {
                new SupervisorUserProject
                {
                    Project          = projects[0],
                    ProjectId        = _projectId1,
                    SupervisorUser   = supervisorWithDataCollectors,
                    SupervisorUserId = _supervisorWithDataCollectorsId
                },
                new SupervisorUserProject
                {
                    Project          = projects[2],
                    ProjectId        = _projectId3,
                    SupervisorUser   = supervisorWithDataCollectors,
                    SupervisorUserId = _supervisorWithDataCollectorsId
                },
                new SupervisorUserProject
                {
                    Project          = projects[1],
                    ProjectId        = _projectId3,
                    SupervisorUser   = supervisorWithoutDataCollectors,
                    SupervisorUserId = _supervisorWithoutDataCollectorsId
                },
                new SupervisorUserProject
                {
                    Project          = projects[0],
                    ProjectId        = _projectId1,
                    SupervisorUser   = supervisorWithDeletedDataCollectors,
                    SupervisorUserId = _supervisorWithDeletedDataCollectorsId
                }
            };

            supervisorWithDataCollectors.SupervisorUserProjects = new List <SupervisorUserProject>
            {
                supervisorUserProjects[0],
                supervisorUserProjects[1]
            };
            supervisorWithoutDataCollectors.SupervisorUserProjects = new List <SupervisorUserProject> {
                supervisorUserProjects[2]
            };
            supervisorWithDeletedDataCollectors.SupervisorUserProjects = new List <SupervisorUserProject> {
                supervisorUserProjects[3]
            };

            supervisorWithDataCollectors.CurrentProject        = supervisorWithDataCollectors.SupervisorUserProjects.Single(p => p.Project.State == ProjectState.Open).Project;
            supervisorWithoutDataCollectors.CurrentProject     = supervisorWithoutDataCollectors.SupervisorUserProjects.Single(p => p.Project.State == ProjectState.Open).Project;
            supervisorWithDeletedDataCollectors.CurrentProject = supervisorWithDeletedDataCollectors.SupervisorUserProjects.Single(p => p.Project.State == ProjectState.Open).Project;

            var userNationalSocieties = new List <UserNationalSociety>
            {
                new UserNationalSociety
                {
                    NationalSociety   = nationalSocieties[0],
                    NationalSocietyId = _nationalSocietyId1,
                    User   = supervisorWithDataCollectors,
                    UserId = _supervisorWithDataCollectorsId
                },
                new UserNationalSociety
                {
                    NationalSociety   = nationalSocieties[0],
                    NationalSocietyId = _nationalSocietyId1,
                    User   = supervisorWithoutDataCollectors,
                    UserId = _supervisorWithoutDataCollectorsId
                },
                new UserNationalSociety
                {
                    NationalSociety   = nationalSocieties[0],
                    NationalSocietyId = _nationalSocietyId1,
                    User   = supervisorWithDeletedDataCollectors,
                    UserId = _supervisorWithDeletedDataCollectorsId
                }
            };

            supervisorWithDataCollectors.UserNationalSocieties = new List <UserNationalSociety> {
                userNationalSocieties[0]
            };
            supervisorWithoutDataCollectors.UserNationalSocieties = new List <UserNationalSociety> {
                userNationalSocieties[1]
            };
            supervisorWithDeletedDataCollectors.UserNationalSocieties = new List <UserNationalSociety> {
                userNationalSocieties[2]
            };

            var dataCollectors = new List <DataCollector>
            {
                new DataCollector
                {
                    Id         = _dataCollectorId,
                    Supervisor = supervisorWithDataCollectors
                },
                new DataCollector
                {
                    Id         = _deletedDataCollectorId,
                    Supervisor = supervisorWithDeletedDataCollectors,
                    DeletedAt  = new DateTime(2020, 01, 01)
                }
            };


            var supervisorUserProjectsDbSet = supervisorUserProjects.AsQueryable().BuildMockDbSet();
            var nationalSocietiesDbSet      = nationalSocieties.AsQueryable().BuildMockDbSet();
            var projectsDbSet = projects.AsQueryable().BuildMockDbSet();
            var usersDbSet    = users.AsQueryable().BuildMockDbSet();
            var userNationalSocietiesDbSet = userNationalSocieties.AsQueryable().BuildMockDbSet();
            var dataCollectorsDbSet        = dataCollectors.AsQueryable().BuildMockDbSet();

            _nyssContext.NationalSocieties.Returns(nationalSocietiesDbSet);
            _nyssContext.Projects.Returns(projectsDbSet);
            _nyssContext.Users.Returns(usersDbSet);
            _nyssContext.SupervisorUserProjects.Returns(supervisorUserProjectsDbSet);
            _nyssContext.UserNationalSocieties.Returns(userNationalSocietiesDbSet);
            _nyssContext.DataCollectors.Returns(dataCollectorsDbSet);


            _nyssContext.NationalSocieties.FindAsync(1).Returns(nationalSocieties[0]);
            _nyssContext.NationalSocieties.FindAsync(2).Returns(nationalSocieties[1]);


            _nationalSocietyUserService.GetNationalSocietyUser <SupervisorUser>(Arg.Any <int>()).Returns(ci =>
            {
                var user = users.OfType <SupervisorUser>().FirstOrDefault(x => x.Id == (int)ci[0]);
                if (user == null)
                {
                    throw new ResultException(ResultKey.User.Registration.UserNotFound);
                }

                return(user);
            });
        }
예제 #17
0
 public DeleteUserServiceTests()
 {
     _httpContextAccessor = Substitute.For <IHttpContextAccessor>();
     _nyssContext         = Substitute.For <INyssContext>();
     _deleteUserService   = new DeleteUserService(_httpContextAccessor, _nyssContext);
 }