Ejemplo n.º 1
0
            public async void Should_return_ok()
            {
                // Arrange
                var book = new Book
                {
                    Title = "Some book",
                };
                var result = new Result();

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

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

                // Assert
                Assert.Same(result, serviceResult);
                Assert.NotNull(serviceResult);
            }
Ejemplo n.º 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");
                AddBookCommandMock
                .Setup(x => x.Execute(book))
                .ReturnsAsync(result);

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

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