IContentRepository implementation for SQL store.
Inheritance: AContentRepository, IContentRepository
Exemplo n.º 1
0
        public void TestExists()
        {
            // Arrange
            var repo =
                new SqlContentRepository(new SqlDataRepository(), "DefaultDatabase", "CmsContent", string.Empty);

            // Act
            var result = repo.Exists(new ContentModel() { Host = "localhost", Path = "/ArticleTitle" });

            // Assert
            Assert.IsTrue(result);
        }
Exemplo n.º 2
0
        public void TestDelete()
        {
            // Arrange
            var repo =
                new SqlContentRepository(new SqlDataRepository(), "DefaultDatabase", "CmsContent", string.Empty);
            var model = new ContentModel() { Host = "localhost", Path = "/test/test/article" };

            // Act
            repo.Remove(model);
            var result = repo.Exists(model);

            // Assert
            Assert.IsFalse(result);
        }
Exemplo n.º 3
0
        public static void MyTestInitialize(TestContext testContext)
        {
            // Arrange
            Bootstrapper.Default.Config = ConfigurationManager.GetSection("phuncms") as ICmsConfiguration;

            var repo =
                new SqlContentRepository(new SqlDataRepository(), "DefaultDatabase", "CmsContent", string.Empty);

            var fileRepo =
                new FileContentRepository(System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "CmsContent"));

            // Act
            var result = fileRepo.Retrieve(new ContentModel() { Host = "localhost", Path = "/ArticleTitle" }, true);
            repo.Save(result);

            result = fileRepo.Retrieve(new ContentModel() { Host = "localhost", Path = "/test/test/article" }, true);
            repo.Save(result);

            result = fileRepo.Retrieve(new ContentModel() { Host = "localhost", Path = "/test/test/article-title" }, true);
            repo.Save(result);
        }
Exemplo n.º 4
0
        public void TestListRootPathReturnsTwoItem()
        {
            // Arrange
            var repo =
                new SqlContentRepository(new SqlDataRepository(), "DefaultDatabase", "CmsContent", string.Empty);
            var model = new ContentModel() { Host = "localhost", Path = "/" };

            // Act
            repo.Save(
                    new ContentModel()
                    {
                        Host = "localhost",
                        Path = "/test/foo/article",
                        Data = System.Text.Encoding.UTF8.GetBytes("test"),
                        CreateBy = string.Empty
                    });
            var result = repo.List(model);

            // Assert
            Assert.AreEqual(2, result.Count());
        }
Exemplo n.º 5
0
        public void TestSaveNewContent()
        {
            // Arrange
            var repo =
                new SqlContentRepository(new SqlDataRepository(), "DefaultDatabase", "CmsContent", string.Empty);

            // Act
            var result = repo.Retrieve(new ContentModel() { Host = "localhost", Path = "/test/test/article-title" });
            repo.Save(
                    new ContentModel()
                    {
                        Host = "localhost",
                        Path = "/test/test/article-title",
                        Data = System.Text.Encoding.UTF8.GetBytes("test")
                    });

            var result2 = repo.Retrieve(new ContentModel() { Host = "localhost", Path = "/test/test/article-title" });

            // Assert
            Assert.IsNotNull(result.Data);
            Assert.IsNotNull(result2.Data);

            Assert.AreNotEqual(System.Text.Encoding.UTF8.GetString(result.Data), System.Text.Encoding.UTF8.GetString(result2.Data));
        }
Exemplo n.º 6
0
        public void TestRetrieveGetContent()
        {
            // Arrange
            var repo =
                new SqlContentRepository(new SqlDataRepository(), "DefaultDatabase", "CmsContent", string.Empty);

            // Act
            var result = repo.Retrieve(new ContentModel() { Host = "localhost", Path = "/ArticleTitle" }, true);

            // Assert
            Assert.IsNotNull(result.Data);
            Assert.IsTrue(result.DataLength > 0);
        }