コード例 #1
0
            public async void Should_return_ok()
            {
                // Arrange
                var book = new Book
                {
                    Title = "Some book",
                };
                var result = new Result();

                UpdateBookCommandMock
                .Setup(x => x.Execute(book))
                .ReturnsAsync(result);

                // Act
                var serviceResult = await ServiceUnderTest.UpdateBookAsync(book);

                // Assert
                Assert.Same(result, serviceResult);
                Assert.NotNull(serviceResult);
            }
コード例 #2
0
            public async void Should_return_error_with_message()
            {
                // Arrange
                var book = new Book
                {
                    Title = "Some book",
                };
                var result = new Result();

                result.AddError("there was an error");
                UpdateBookCommandMock
                .Setup(x => x.Execute(book))
                .ReturnsAsync(result);

                // Act
                var serviceResult = await ServiceUnderTest.UpdateBookAsync(book);

                // Assert
                Assert.Same(result, serviceResult);
                Assert.NotNull(serviceResult);
                Assert.Equal(result.Errors.First(), serviceResult.Errors.First());
            }