Beispiel #1
0
        public void Handle_ListBookFilteringQuery_Filter_Language()
        {
            // arrange
            var key = MockBuilder.Key;

            var book = BookMock.Get(key);

            MockRepository.Add(book);

            var key2 = MockBuilder.Key;

            var book2 = BookMock.Get(key2);

            book2.Language = Language.Portuguese;
            MockRepository.Add(book2);

            MockRepository.Commit();

            var query = ListBookFilteringQueryMock.Get(key);

            query.Language = book2.Language;

            // act
            var dto = Handle(query);

            dto.Should().NotBeNull();

            var dtoExpected = BookDtoMock.Get(key2);

            dtoExpected.Language = book2.Language;
            dto.Should().BeEquivalentTo(MockBuilder.List(dtoExpected).ToPagedResponse());
        }
Beispiel #2
0
        public void Handle_ListBookFilteringQuery_Multiple()
        {
            // arrange
            var key = MockBuilder.Key;

            var book = BookMock.Get(key);

            MockRepository.Add(book);

            var key2 = MockBuilder.Key;

            var book2 = BookMock.Get(key2);

            MockRepository.Add(book2);

            MockRepository.Commit();

            var query = ListBookFilteringQueryMock.Get(key);

            // act
            var dto = Handle(query);

            dto.Should().NotBeNull();

            var dtoExpected  = BookDtoMock.Get(key);
            var dtoExpected2 = BookDtoMock.Get(key2);

            dto.Should().BeEquivalentTo(MockBuilder.List(dtoExpected, dtoExpected2).ToPagedResponse());
        }
Beispiel #3
0
        public void Handle_GetBookQuery_Default()
        {
            // arrange
            var key = MockBuilder.Key;

            var book = BookMock.Get(key);

            MockRepository.Add(book);

            MockRepository.Commit();

            var query = GetBookQueryMock.Get(key);

            // act
            var dto = Handle(query);

            dto.Should().NotBeNull();

            var dtoExpected = BookDtoMock.Get(key);

            dto.Should().BeEquivalentTo(dtoExpected);
        }
Beispiel #4
0
        public void Handle_ListBookFilteringQuery_Filter_Category()
        {
            // arrange
            var key = MockBuilder.Key;

            var book = BookMock.Create(key)
                       .Default()
                       .WithCategory()
                       .Build();

            MockRepository.Add(book);

            var key2 = MockBuilder.Key;

            var book2 = BookMock.Create(key2)
                        .Default()
                        .WithCategory()
                        .Build();

            MockRepository.Add(book2);

            MockRepository.Commit();

            var query = ListBookFilteringQueryMock.Get(key);

            query.Category = Fake.GetCategoryName(key2);

            // act
            var dto = Handle(query);

            dto.Should().NotBeNull();

            var dtoExpected = BookDtoMock.Get(key2);

            dto.Should().BeEquivalentTo(MockBuilder.List(dtoExpected).ToPagedResponse());
        }