示例#1
0
            public async void Should_return_ok_with_success()
            {
                // Arrange
                var genre = new Genre
                {
                    Name = "Peter Piper"
                };
                var result = new Result();

                AddGenreCommandMock
                .Setup(x => x.Execute(genre))
                .ReturnsAsync(result);

                // Act
                var serviceResult = await ServiceUnderTest.AddGenreAsync(genre);

                // Assert
                Assert.Same(result, serviceResult);
                Assert.True(serviceResult.IsSuccess);
            }
示例#2
0
            public async void Should_return_error_with_message()
            {
                // Arrange
                var genre = new Genre
                {
                    Name = "Peter Piper"
                };
                var result = new Result();

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

                // Act
                var serviceResult = await ServiceUnderTest.AddGenreAsync(genre);

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