Esempio n. 1
0
        public static string ToUrlFriendlyFileNameWithExtension(this string fileNameWithExtension, ISlugFactory slugFactory)
        {
            var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileNameWithExtension);
            var extension   = Path.GetExtension(fileNameWithExtension);
            var urlFriendly = slugFactory.CreateSlug(fileNameWithoutExtension) + extension;

            return(urlFriendly);
        }
Esempio n. 2
0
        public string GetBlogRelativeUri()
        {
            var uri = string.Format("{0}/{1}/{2}", "blog", Published.ToUniversalTime().ToFolders(), _slugFactory.CreateSlug(Title));

            return(uri);
        }
Esempio n. 3
0
        public void ThenTheFileShouldBeCommittedToTheMasterBranchOfTheGitRepository()
        {
            var method = _invocationRecorder.CallsTo <IGitRepository>().SingleOrDefault(i => i.Method.Name == "CommitAsync");

            method.Should().NotBeNull();

            const GitBranches expectedBranch = GitBranches.Master;
            var expectedRelativePath         = string.Format("blog/{0}/{1}.md", _given.Published.ToUniversalTime().DateTime.ToFolders(), _slugFactory.CreateSlug(_given.Title));
            var expectedMessage = string.Format("Published blog post '{0}'.", _given.BlogPost.Title);
            var expectedAuthor  = _given.Author;

            // ReSharper disable once PossibleNullReferenceException
            var arguments = method.Arguments;

            arguments[0].Should().Be(expectedBranch);
            arguments[1].Should().Be(expectedRelativePath);
            arguments[2].Should().Be(expectedMessage);

            var actualAuthor = (Author)arguments[3];

            actualAuthor.Email.Should().Be(expectedAuthor.Email);
            actualAuthor.Name.Should().Be(expectedAuthor.Name);
            actualAuthor.TimeZoneInfo.Should().Be(expectedAuthor.TimeZoneInfo);
        }