public void ShouldParseCommaDelimitedTagsAndSpaceDelimitedTagInput() { var command = new NewThreadCommand { Tags = "tags,test", TagInput = "hogs baseball" }; command.AllTagsEntered.ShouldContain("tags"); command.AllTagsEntered.ShouldContain("test"); command.AllTagsEntered.ShouldContain("hogs"); command.AllTagsEntered.ShouldContain("baseball"); }
public FubuContinuation NewThread(NewThreadCommand command) { var thread = new DiscussionThread(command.Title, command.Body, command.AllTagsEntered, command.Author); _session.Store(thread); _session.SaveChanges(); return FubuContinuation.RedirectTo(new ViewThreadRequest { UriId = thread.UriId, Title = thread.Title }); }
public void CreatesNewThreadAndSavesIt() { var endpoint = TestableNewThreadEndpoint.Build(); var command = new NewThreadCommand { Tags = "test,tags", TagInput = "hogs baseball", Author = new UserAccount() }; var request = new ViewThreadRequest(); endpoint.Mapper .Setup(x => x.Map<DiscussionThread, ViewThreadRequest>(It.IsAny<DiscussionThread>())) .Returns(request); var continuation = endpoint.NewThread(command); endpoint.Session.Verify(x => x.Store(It.IsAny<DiscussionThread>())); continuation.AssertWasRedirectedTo<ViewThreadRequest>(); }
public void TagsOrTagInputMustBeSupplied() { var validator = new NewThreadCommandValidator(); var command = new NewThreadCommand(); validator.ShouldHaveValidationErrorFor(x => x.TagInput, command); command.Tags = "test"; validator.ShouldNotHaveValidationErrorFor(x => x.TagInput, command); command.Tags = null; command.TagInput = "test"; validator.ShouldNotHaveValidationErrorFor(x => x.TagInput, command); command.Tags = "test"; validator.ShouldNotHaveValidationErrorFor(x => x.TagInput, command); }