Пример #1
0
        public async void ShouldReturnAllBooksFromTheRepository()
        {
            // Arrange
            var bookToCreate = new Book
            {
                Title  = "The wind in the willows",
                ISBN10 = "1515151515"
            };

            var createdId = await _fixture.AddAsync(bookToCreate);

            var query = new GetBooksQuery();

            // Act
            var result = await _fixture.SendAsync(query);

            // Assert
            result.ShouldNotBeNull();
            result.Count.ShouldBeGreaterThan(0);

            var createdBook = result.Single(x => x.Id == createdId);

            createdBook.ShouldNotBeNull();
            createdBook.ISBN10.ShouldBe("1515151515");
            createdBook.Title.ShouldBe("The wind in the willows");
        }
        //[Fact]
        public async void ShouldReturnAllListsAndItems()
        {
            var createdId = await _fixture.AddAsync(new TodoList
            {
                Title = "Shopping 30/10/2020",
                Items =
                {
                    new TodoItem {
                        Title = "Apples"
                    },
                    new TodoItem {
                        Title = "Milk"
                    },
                    new TodoItem {
                        Title = "Bread"
                    },
                    new TodoItem {
                        Title = "Toilet paper"
                    },
                    new TodoItem {
                        Title = "Pasta"
                    },
                    new TodoItem {
                        Title = "Tissues"
                    },
                    new TodoItem {
                        Title = "Tuna"
                    }
                }
            });

            var confirmCreation = await _fixture.FindAsync <TodoList>(createdId);

            confirmCreation.ShouldNotBeNull();

            var query = new GetTodosQuery();

            var result = await _fixture.SendAsync(query);

            var createdList = result.Lists.Single(x => x.Title == "Shopping 30/10/2020");

            createdList.ShouldNotBeNull();
            createdList.Items.Count.ShouldBe(7);
        }