예제 #1
0
            public async void Should_return_ok_with_success()
            {
                // Arrange
                var author = new Author
                {
                    Name = "Peter Piper"
                };
                var result = new Result();

                AddAuthorCommandMock
                .Setup(x => x.Execute(author))
                .ReturnsAsync(result);

                // Act
                var serviceResult = await ServiceUnderTest.AddAuthorAsync(author);

                // Assert
                Assert.Same(result, serviceResult);
                Assert.True(serviceResult.IsSuccess);
            }
예제 #2
0
            public async void Should_return_error_with_message()
            {
                // Arrange
                var author = new Author
                {
                    Name = "Peter Piper"
                };
                var result = new Result();

                result.AddError("no thank you");
                AddAuthorCommandMock
                .Setup(x => x.Execute(author))
                .ReturnsAsync(result);

                // Act
                var serviceResult = await ServiceUnderTest.AddAuthorAsync(author);

                // Assert
                Assert.Same(result, serviceResult);
                Assert.NotEmpty(serviceResult.Errors);
                Assert.False(serviceResult.IsSuccess);
            }