示例#1
0
    public void Can_Update()
    {
        var content = CreateTestData(3).ToArray();

        var provider = ScopeProvider;

        using (var scope = provider.CreateScope())
        {
            var repo = new PublicAccessRepository((IScopeAccessor)provider, AppCaches, LoggerFactory.CreateLogger <PublicAccessRepository>());

            PublicAccessRule[] rules = { new PublicAccessRule {
                                             RuleValue = "test", RuleType = "RoleName"
                                         } };
            var entry = new PublicAccessEntry(content[0], content[1], content[2], rules);
            repo.Save(entry);

            // re-get
            entry = repo.Get(entry.Key);

            entry.Rules.First().RuleValue = "blah";
            entry.Rules.First().RuleType  = "asdf";
            repo.Save(entry);

            // re-get
            entry = repo.Get(entry.Key);

            Assert.AreEqual("blah", entry.Rules.First().RuleValue);
            Assert.AreEqual("asdf", entry.Rules.First().RuleType);
        }
    }
        public void Can_Delete()
        {
            var content = CreateTestData(3).ToArray();

            var provider = TestObjects.GetScopeProvider(Logger);

            using (var scope = provider.CreateScope())
            {
                var repo = new PublicAccessRepository((IScopeAccessor)provider, CacheHelper, Logger);

                var entry = new PublicAccessEntry(content[0], content[1], content[2], new[]
                {
                    new PublicAccessRule
                    {
                        RuleValue = "test",
                        RuleType  = "RoleName"
                    },
                });
                repo.Save(entry);


                repo.Delete(entry);


                entry = repo.Get(entry.Key);
                Assert.IsNull(entry);
            }
        }
示例#3
0
        public void Can_Delete()
        {
            var content = CreateTestData(3).ToArray();

            var provider   = new PetaPocoUnitOfWorkProvider(Logger);
            var unitOfWork = provider.GetUnitOfWork();

            using (var repo = new PublicAccessRepository(unitOfWork, CacheHelper, Logger, SqlSyntax))
            {
                var entry = new PublicAccessEntry(content[0], content[1], content[2], new[]
                {
                    new PublicAccessRule
                    {
                        RuleValue = "test",
                        RuleType  = "RoleName"
                    },
                });
                repo.AddOrUpdate(entry);
                unitOfWork.Commit();

                repo.Delete(entry);
                unitOfWork.Commit();

                entry = repo.Get(entry.Key);
                Assert.IsNull(entry);
            }
        }
示例#4
0
        public void Can_Delete()
        {
            IContent[] content = CreateTestData(3).ToArray();

            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                var repo = new PublicAccessRepository((IScopeAccessor)provider, AppCaches, LoggerFactory.CreateLogger <PublicAccessRepository>());

                PublicAccessRule[] rules = new[]
                {
                    new PublicAccessRule
                    {
                        RuleValue = "test",
                        RuleType  = "RoleName"
                    },
                };
                var entry = new PublicAccessEntry(content[0], content[1], content[2], rules);
                repo.Save(entry);

                repo.Delete(entry);

                entry = repo.Get(entry.Key);
                Assert.IsNull(entry);
            }
        }
        public void Can_Update()
        {
            var content = CreateTestData(3).ToArray();

            var provider = TestObjects.GetScopeProvider(Logger);

            using (var scope = provider.CreateScope())
            {
                var repo = new PublicAccessRepository((IScopeAccessor)provider, CacheHelper, Logger);

                var entry = new PublicAccessEntry(content[0], content[1], content[2], new[]
                {
                    new PublicAccessRule
                    {
                        RuleValue = "test",
                        RuleType  = "RoleName"
                    },
                });
                repo.Save(entry);


                //re-get
                entry = repo.Get(entry.Key);

                entry.Rules.First().RuleValue = "blah";
                entry.Rules.First().RuleType  = "asdf";
                repo.Save(entry);



                //re-get
                entry = repo.Get(entry.Key);

                Assert.AreEqual("blah", entry.Rules.First().RuleValue);
                Assert.AreEqual("asdf", entry.Rules.First().RuleType);
            }
        }
示例#6
0
    public void Get_By_Id()
    {
        var content = CreateTestData(3).ToArray();

        var provider = ScopeProvider;

        using (var scope = provider.CreateScope())
        {
            var repo = new PublicAccessRepository((IScopeAccessor)provider, AppCaches, LoggerFactory.CreateLogger <PublicAccessRepository>());

            PublicAccessRule[] rules = { new PublicAccessRule {
                                             RuleValue = "test", RuleType = "RoleName"
                                         } };
            var entry = new PublicAccessEntry(content[0], content[1], content[2], rules);
            repo.Save(entry);

            // re-get
            entry = repo.Get(entry.Key);

            Assert.IsNotNull(entry);
        }
    }