Example #1
0
        public void IsAuthorizedFor_CachesAccountPermissions()
        {
            Int32 accountId = CreateAccountWithPermissionFor(null, "Authorized", "Action");

            context.DropData();

            Assert.True(authorization.IsAuthorizedFor(accountId, null, "Authorized", "Action"));
        }
Example #2
0
 public MvcLookupTests()
 {
     url    = Substitute.For <IUrlHelper>();
     lookup = new MvcLookup <Role, RoleView>(url);
     using (TestingContext context = new TestingContext())
         context.DropData();
 }
Example #3
0
        public AuthorizationProviderTests()
        {
            authorization = new AuthorizationProvider(Assembly.GetExecutingAssembly());
            context       = new TestingContext();

            context.DropData();
        }
Example #4
0
        public void IsAuthorizedFor_CachesAccountPermissions()
        {
            Account account = CreateAccountWithPermissionFor(null, "Authorized", "Action");

            using (TestingContext context = new TestingContext()) context.DropData();

            Assert.True(authorization.IsAuthorizedFor(account.Id, null, "Authorized", "Action"));
        }
        public AuthorizationProviderTests()
        {
            serviceProvider = Substitute.For <IServiceProvider>();
            serviceProvider.GetService(typeof(IUnitOfWork)).Returns(info => new UnitOfWork(new TestingContext()));

            using (TestingContext context = new TestingContext()) context.DropData();
            provider = new AuthorizationProvider(Assembly.GetExecutingAssembly(), serviceProvider);
        }
        public SelectTests()
        {
            context = new TestingContext();
            select  = new Select <Role>(context.Set <Role>());

            context.DropData();
            SetUpData();
        }
Example #7
0
        public SelectTests()
        {
            context = new TestingContext();
            select  = new Select <Role>(context.Set <Role>());

            context.Set <Role>().Add(ObjectFactory.CreateRole());
            context.DropData();
        }
Example #8
0
        public void IsAuthorizedFor_CachesAccountPrivileges()
        {
            Account account = CreateAccountWithPrivilegeFor(null, "Authorized", "Action");

            using (TestingContext context = new TestingContext()) context.DropData();

            Assert.True(provider.IsAuthorizedFor(account.Id, null, "Authorized", "Action"));
        }
Example #9
0
        public RoleServiceTests()
        {
            context = new TestingContext();
            service = Substitute.ForPartsOf <RoleService>(new UnitOfWork(context));

            context.DropData();
            SetUpData();
        }
        public RoleServiceTests()
        {
            context = new TestingContext();
            Authorization.Provider = Substitute.For <IAuthorizationProvider>();
            service = Substitute.ForPartsOf <RoleService>(new UnitOfWork(context));

            context.DropData();
        }
Example #11
0
        public UnitOfWorkTests()
        {
            context    = new TestingContext();
            model      = ObjectFactory.CreateRole();
            unitOfWork = new UnitOfWork(context);

            context.DropData();
        }
Example #12
0
        public StateServiceTests()
        {
            context = new TestingContext();
            service = new StateService(new UnitOfWork(context));

            context.DropData();
            SetUpData();
        }
Example #13
0
        public MvcDatalistTests()
        {
            HttpContext.Current = HttpContextFactory.CreateHttpContext();
            url = new UrlHelper(HttpContext.Current.Request.RequestContext);

            datalist = new MvcDatalist <Role, RoleView>(url);
            using (TestingContext context = new TestingContext()) context.DropData();
        }
Example #14
0
        public CountryValidatorTests()
        {
            context   = new TestingContext();
            validator = new CountryValidator(new UnitOfWork(context));

            context.DropData();
            SetUpData();
        }
Example #15
0
        public UnitOfWorkTests()
        {
            context    = new TestingContext();
            model      = ObjectFactory.CreateRole();
            logger     = Substitute.For <IAuditLogger>();
            unitOfWork = new UnitOfWork(context, logger);

            context.DropData();
        }
Example #16
0
        public UnitOfWorkTests()
        {
            context    = new TestingContext();
            model      = ObjectFactory.CreateTestModel();
            logger     = Substitute.For <IAuditLogger>();
            unitOfWork = new UnitOfWork(context, logger);

            context.Set <TestModel>().RemoveRange(context.Set <TestModel>());
            context.DropData();
        }
        public RoleValidatorTests()
        {
            context   = new TestingContext();
            validator = new RoleValidator(new UnitOfWork(context));

            context.DropData();

            context.Add(role = ObjectFactory.CreateRole());
            context.SaveChanges();
        }
        public AuditLoggerTests()
        {
            context = new TestingContext();
            logger  = new AuditLogger(context, 1);
            TestModel      model       = ObjectFactory.CreateTestModel();
            TestingContext dataContext = new TestingContext();

            entry = dataContext.Entry <BaseModel>(dataContext.Set <TestModel>().Add(model));
            dataContext.Set <AuditLog>().RemoveRange(dataContext.Set <AuditLog>());
            dataContext.DropData();
        }
Example #19
0
        public void Refresh_Permissions()
        {
            Account account = CreateAccountWithPermissionFor("Area", "Authorized", "Action");

            Assert.True(authorization.IsAuthorizedFor(account.Id, "Area", "Authorized", "Action"));

            using (TestingContext context = new TestingContext()) context.DropData();

            authorization.Refresh();

            Assert.False(authorization.IsAuthorizedFor(account.Id, "Area", "Authorized", "Action"));
        }
Example #20
0
        public AccountServiceTests()
        {
            context = new TestingContext();
            hasher  = Substitute.For <IHasher>();
            hasher.HashPassword(Arg.Any <String>()).Returns(info => info.Arg <String>() + "Hashed");

            context.DropData();
            SetUpData();

            service = new AccountService(new UnitOfWork(context), hasher);
            service.CurrentAccountId = account.Id;
        }
Example #21
0
        public AccountValidatorTests()
        {
            context = new TestingContext();
            hasher  = Substitute.For <IHasher>();
            hasher.VerifyPassword(Arg.Any <String>(), Arg.Any <String>()).Returns(true);

            context.DropData();
            SetUpData();

            validator = new AccountValidator(new UnitOfWork(context), hasher);
            validator.CurrentAccountId = account.Id;
        }
        public LoggableEntityTests()
        {
            using (context = new TestingContext())
            {
                context.DropData();
                SetUpData();
            }

            context = new TestingContext();
            model   = context.Set <Role>().Single();
            entry   = context.Entry <BaseModel>(model);
        }
        public void Refresh_Permissions()
        {
            Account account = CreateAccountWithPermissionFor("Area", "Authorized", "Action");

            Assert.True(provider.IsAuthorizedFor(account.Id, "Area", "Authorized", "Action"));

            using (TestingContext context = new TestingContext()) context.DropData();
            SetUpDependencyResolver();

            provider.Refresh();

            Assert.False(provider.IsAuthorizedFor(account.Id, "Area", "Authorized", "Action"));
        }
Example #24
0
        public LoggableEntityTests()
        {
            using (context = new TestingContext())
            {
                context.Set <TestModel>().RemoveRange(context.Set <TestModel>());
                context.Set <TestModel>().Add(ObjectFactory.CreateTestModel());
                context.Set <Role>().Add(ObjectFactory.CreateRole());
                context.DropData();
            }

            context = new TestingContext();
            model   = context.Set <TestModel>().Single();
            entry   = context.Entry <BaseModel>(model);
        }
Example #25
0
 public BaseLookupTests()
 {
     urlHelper = Substitute.For <IUrlHelper>();
     lookup    = new BaseLookupProxy <Role, RoleView>(urlHelper);
     using (TestingContext context = new TestingContext()) context.DropData();
 }