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

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

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

                // Assert
                Assert.Same(result, serviceResult);
                Assert.NotNull(serviceResult.Value);
                Assert.Same(book, serviceResult.Value);
            }
Ejemplo n.º 2
0
            public async void Should_return_error_with_message()
            {
                // Arrange
                var book = new Book
                {
                    Title = "Some book",
                };
                var result = new Result <Book>();

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

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

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