コード例 #1
0
        public void InvalidPost()
        {
            A.CallTo(() => this.validators.Create.Validate(A<Post>.Ignored))
             .Returns(
                 new ValidationResult(new List<ValidationFailure> { new ValidationFailure("Author", "Mandatory") }));

            var command = new CreatePostCommand(this.stream, this.service, this.validators);

            command.Execute();

            Assert.That(command.IsSuccessful, Is.False);
            Assert.That(command.Results.IsValid, Is.False);
            Assert.That(command.Results.Errors.Count, Is.EqualTo(1));
        }
コード例 #2
0
 public void TearDown()
 {
     this.service = null;
     this.createCommand = null;
     this.updateCommand = null;
     this.connection = null;
 }
コード例 #3
0
 public void Setup()
 {
     this.service = A.Fake<IPostService>();
     this.createCommand = A.Fake<CreatePostCommand>();
     this.updateCommand = A.Fake<UpdatePostCommand>();
     this.connection = A.Fake<IConnectionManager>();
 }
コード例 #4
0
        public void ValidPost()
        {
            A.CallTo(() => this.validators.Create.Validate(A<Post>.Ignored)).Returns(new ValidationResult());

            A.CallTo(() => this.service.Create(A<Post>.That.Matches(x => x.Author == "Jon" && x.Content == "Test")))
             .Returns(true);

            var command = new CreatePostCommand(this.stream, this.service, this.validators);

            command.Author = "Jon";
            command.Content = "Test";

            command.Execute();

            Assert.That(command.IsSuccessful, Is.True);
            Assert.That(command.Results.IsValid, Is.True);
            Assert.That(command.Results.Errors.Count, Is.EqualTo(0));
            A.CallTo(() => this.service.Create(A<Post>.That.Matches(x => x.Author == "Jon" && x.Content == "Test")))
             .MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => this.stream.Raise(A<PostWasCreated>.Ignored)).MustHaveHappened(Repeated.Exactly.Once);
        }