public async Task GetAll_Valid_Success()
        {
            DateTime dtStart = DateTime.Now;

            await ExecuteWithDb((db) =>
            {
                var handler = new LibraryQueryHandler(
                    MockMediator.Object,
                    db,
                    Mapper,
                    MockAuthorizationService.Object);

                return(handler.Handle(new GetAllLibraryQuery(), default(CancellationToken)));
            }, (result, db) => {
                result.Should().NotBeNull();
                result.Should().BeAssignableTo <IEnumerable <LibraryDto> >();
                result.Should().HaveCountGreaterThan(0);
                foreach (var library in result)
                {
                    library.Id.Should().BeGreaterThan(0);
                    library.Name.Should().NotBeNullOrWhiteSpace();
                    library.Address.Should().NotBeNull();
                    library.CreatedDate.Should().BeOnOrAfter(dtStart);
                    library.UpdatedDate.Should().BeOnOrAfter(dtStart);
                }
            });
        }
 public async Task GetById_IdNotFound_entityNotFoundException(int id)
 {
     await ExecuteWithDb((db) =>
     {
         var handler = new LibraryQueryHandler(
             MockMediator.Object,
             db,
             Mapper,
             MockAuthorizationService.Object);
         return(handler.Handle(new GetLibraryByIdQuery()
         {
             LibraryId = id
         }, default(CancellationToken)));
     });
 }
        public async Task GetById_Valid_Success()
        {
            await ExecuteWithDb((db) =>
            {
                var dto = SeedHelper.GetRandomLibrary(db);

                var handler = new LibraryQueryHandler(
                    MockMediator.Object,
                    db,
                    Mapper,
                    MockAuthorizationService.Object);

                return(handler.Handle(new GetLibraryByIdQuery()
                {
                    LibraryId = dto.Id
                }, default(CancellationToken)));
            }, (result, db) => {
                result.Should().NotBeNull();
                result.Should().BeAssignableTo <LibraryDto>();
                result.Id.Should().BeGreaterThan(0);
                result.Name.Should().NotBeNullOrWhiteSpace();
                result.Address.Should().NotBeNull();
            });
        }