コード例 #1
0
        public void ConfigurationPopulatesAuthors()
        {
            (string GitDirectory, string ContentDirectory) = GetSrc.SrcPath();
            Configuration configuration = new Configuration(GitDirectory, ContentDirectory);

            configuration.Defaults.Authors.Should().NotBeEmpty();
        }
コード例 #2
0
        public void IgnoresNonContentDirectories()
        {
            List <string> mockChanges = new List <string>()
            {
                ".gitignore",
                ".vsts-content-manager.yml",
                "content/ContentManager/ContentManager.Test/ContentManager.Test.csproj",
                "content/ContentManager/ContentManager.Test/GetFilesShould.cs",
                "content/ContentManager/ContentManager.Test/Properties/launchSettings.json",
                "content/ContentManager/ContentManager.Test/scripts/checkCoverage.js",
                "content/ContentManager/ContentManager.sln",
                "content/ContentManager/ContentManager/GetFiles.cs",
                "content/ContentManager/ContentManager/Models.cs",
                "content/ContentManager/ContentManager/Options.cs",
                "content/ContentManager/ContentManager/Program.cs",
                "content/ContentManager/ContentManager/Properties/launchSettings.json",
                "content/ContentManager/ContentManager/Types.cs",
                "content/ContentManager/ContentManagerTest/UnitTest1.cs",
                "content/ContentManager/README.md",
                "backend/someFile.tf",
                "frontend/someOtherFile.js"
            };

            Mock <IRepository> mockRepo = new Mock <IRepository>();

            (string GitDirectory, string ContentDirectory) = GetSrc.SrcPath();
            GetFilesFromDiff gitHelper = new GetFilesFromDiff(mockRepo.Object, GitDirectory, "content");
            Dictionary <Types.InputType, IEnumerable <string> > files = gitHelper.PackPaths(mockChanges as IEnumerable <string>);

            Assert.Empty(files);
        }
コード例 #3
0
        public void ThumbnailsMustBeDefined()
        {
            (string GitDirectory, string ContentDirectory) = GetSrc.SrcPath();
            Configuration configuration = new Configuration(GitDirectory, ContentDirectory);

            configuration.Defaults.Thumbnails.Should().NotBeEmpty();
        }
コード例 #4
0
        public void ReturnTheModelAsAString()
        {
            Dictionary <Types.InputType, Func <string, string> > configuration = FileManager.TypeToImplementationDict();

            (string _, string ContentDirectory) = GetSrc.SrcPath();
            string combinedPath = Path.Combine(ContentDirectory, "blog");

            combinedPath = Path.Combine(combinedPath, "posts");
            combinedPath = Path.Combine(combinedPath, "the-mothfng-facebook-feed-dialog.md");
            Func <string, string> implementation = configuration[Types.InputType.blog];
            string model = implementation(combinedPath);
        }
コード例 #5
0
        public void GetsRepositoryProperties()
        {
            (string GitDirectory, string ContentDirectory) = GetSrc.SrcPath();
            RepositorySettings props = Git.GetCurrentGithubProperties(GitDirectory);

            props.User.Should().NotBeEmpty("User needs to be defined");
            props.Branch.Should().NotBeEmpty("Branch needs to be defined");
            props.Repository.Should().NotBeEmpty("Repository needs to be defined");
            props.User.Should().NotBeNullOrWhiteSpace("User needs to be defined");
            props.Branch.Should().NotBeNullOrWhiteSpace("Branch needs to be defined");
            props.Repository.Should().NotBeNullOrWhiteSpace("Repository needs to be defined");
        }
コード例 #6
0
        public void ReturnsContentSpecificFolder(Types.InputType type)
        {
            (string GitDirectory, string ContentDirectory) = GetSrc.SrcPath();
            Configuration configuration = new Configuration(GitDirectory, ContentDirectory)
            {
                InputType = type,
                BuildType = Types.BuildType.origin,
                Verbose   = false
            };

            configuration.TypesToProcess = configuration.GetTypes();
            Func <Configuration, Dictionary <Types.InputType, IEnumerable <string> > > gitHelper = MockWrapGit;
            Dictionary <Types.InputType, IEnumerable <string> > files = GetFiles.FromBuildType(configuration, gitHelper);

            AnallyExpect.MarkdownXmlOrOpmlFilesOnSingleType(type, files);
        }
コード例 #7
0
        public void GetUrlWithBranchReturnsFullyQualifiedUrl()
        {
            (string GitDirectory, string ContentDirectory) = GetSrc.SrcPath();
            Configuration config = new Configuration(GitDirectory, ContentDirectory);

            foreach (var image in config.Defaults.Thumbnails)
            {
                string pathToThumbnail = image.File;
                Uri    uriToAsset      = Git.AssembleUrlToAssetOnGithub(config.GithubProperties, ContentDirectory, pathToThumbnail);
                uriToAsset.Host.Should().Be("raw.githubusercontent.com");
                string   localPath  = uriToAsset.LocalPath.Substring(1);
                string[] pathPieces = localPath.Split('/');
                pathPieces[0].Should().Be(config.GithubProperties.User);
                pathPieces[1].Should().Be(config.GithubProperties.Repository);
                pathPieces[2].Should().Be(config.GithubProperties.Branch);
                localPath.Should().EndWith(image.File);
            }
        }
コード例 #8
0
        public void ReturnsContentSpecificFolder(Types.InputType type, IEnumerable <string> list, int fileCount)
        {
            Mock <IRepository> mockRepo = new Mock <IRepository>();

            (string GitDirectory, string ContentDirectory) = GetSrc.SrcPath();
            GetFilesFromDiff gitHelper = new GetFilesFromDiff(mockRepo.Object, GitDirectory, "content");
            Dictionary <Types.InputType, IEnumerable <string> > files = gitHelper.PackPaths(list as IEnumerable <string>);

            Assert.Single(files);
            foreach (KeyValuePair <Types.InputType, IEnumerable <string> > entry in files)
            {
                Assert.Equal(type, entry.Key);
                Assert.Equal(fileCount, entry.Value.Count());
                foreach (string file in entry.Value)
                {
                    AnallyExpect.MarkDownOrXmlFiles(file);
                    Assert.Contains(type.ToString("g"), file);
                }
            }
        }