Example #1
0
        public void ThenTheBlogPostShouldBeCreated()
        {
            var publishAsync     = _invocationRecorder.CallsTo <IMarkdownDocumentRepository <BlogPost> >().Single(m => m.Method.Name == "PublishAsync");
            var expectedBlogPost = new BlogPost((PublishBlogPost)_given.Command);
            var actualBlogPost   = (BlogPost)publishAsync.Arguments[0];

            actualBlogPost.ShouldBeEquivalentTo(expectedBlogPost);
        }
Example #2
0
        public void ThenTheFileShouldBeSaved()
        {
            var methods   = _invocationRecorder.CallsTo <IFileRepository>();
            var method    = methods.Single(m => m.Method.Name == "PublishAsync");
            var parameter = (UploadedFile)method.Arguments[0];
            var command   = (UploadFile)_given.Command;

            parameter.RelativeUri.Should().Be(Path.Combine(command.RelativeDirectory, command.UrlFriendlyFileNameWithExtension));
        }
Example #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);
        }