Inheritance: AContentRepository, IContentRepository
        public void TestExistsFindFileOnSystem()
        {
            // Arrange
            var repo =
                new FileContentRepository(System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "CmsContent"));

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

            // Assert
            Assert.IsTrue(result);
        }
        public void TestRetrieveGetContentFromFile()
        {
            // Arrange
            var repo =
                new FileContentRepository(System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "CmsContent"));

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

            // Assert
            Assert.IsNotNull(result.Data);
            Assert.IsTrue(result.DataLength > 0);
        }
        public void TestListRootPathReturnsTwoItem()
        {
            // Arrange
            var repo =
                new FileContentRepository(System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "CmsContent"));
            var model = new ContentModel() { Host = "localhost", Path = "/" };

            // Act
            var result = repo.List(model);

            // Assert
            Assert.IsTrue(result.Count() == 2);
        }
        public void TestDeleteFile()
        {
            // Arrange
            var repo =
                new FileContentRepository(System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "CmsContent"));
            var model = new ContentModel() { Host = "localhost", Path = "/test/test/article" };

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

            // Assert
            Assert.IsFalse(result);
        }
Ejemplo n.º 5
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);
        }
        public void TestSaveNewContentToFile()
        {
            // Arrange
            var repo =
                new FileContentRepository(System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "CmsContent"));

            // 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.SetDataFromStream().Data);
            Assert.IsNotNull(result2.SetDataFromStream().Data);
            Assert.AreNotEqual(result.Data, result2.Data);
        }