Ejemplo n.º 1
0
        private AccountsController GetAccountsControllerAdmin(MockAccountService mockService, MockUserManager mockUserManager, MockUserValidator mockUserValidator)
        {
            var authService = MockAuthorizationService.BuildAuthorizationService(services =>
            {
                services.AddScoped <IAccountService>(sp => mockService.Object);
                services.AddScoped <IAuthorizationHandler, AdminAuthorizationHandler>();
            });

            var controller = new AccountsController(authService, mockUserManager.Object, mockUserValidator.Object, mockService.Object);

            MockAuthorizationService.SetupUserWithRole(controller, Constants.UserAdministratorsRole);

            return(controller);
        }
Ejemplo n.º 2
0
        private SesshinsController GetSesshinsController(MockSesshinService mockSesshin)
        {
            var authService = MockAuthorizationService.BuildAuthorizationService(services =>
            {
                services.AddScoped <ISesshinService>(sp => mockSesshin.Object);
                services.AddScoped <IAuthorizationHandler, AdminAuthorizationHandler>();
            });

            var controller = new SesshinsController(mockSesshin.Object, authService);

            MockAuthorizationService.SetupUserWithRole(controller, Constants.UserAdministratorsRole);

            return(controller);
        }
Ejemplo n.º 3
0
        private MealsController GetMealsController(MockMealService mockService, bool addRole)
        {
            var authService = MockAuthorizationService.BuildAuthorizationService(services =>
            {
                services.AddScoped <IMealService>(sp => mockService.Object);
                services.AddScoped <IAuthorizationHandler, AdminAuthorizationHandler>();
            });

            var controller = new MealsController(mockService.Object, authService);

            if (addRole)
            {
                MockAuthorizationService.SetupUserWithRole(controller, Constants.UserAdministratorsRole);
            }

            return(controller);
        }