public async void UpdateBookDetail_Success() { var mockDb = _repositoryMock as MockBookRepository <Domain.Entities.Subscription>; mockDb.Table.Add(Guid.NewGuid(), new Domain.Entities.Subscription(Guid.NewGuid(), Guid.NewGuid(), "Book 1")); mockDb.Table.Add(Guid.NewGuid(), new Domain.Entities.Subscription(Guid.NewGuid(), Guid.NewGuid(), "Book 2")); var query = new GetAllSubscriptionsQuery(); var booksQuery = new GetAllSubscriptionsQueryHandler(_repositoryMock); var result = await booksQuery.HandleAsync(query); Assert.Equal(2, result.ToList().Count); }
protected override async Task <IList <SubscriptionDto> > HandleQueryAsync(GetAllSubscriptionsQuery query) { return (await _session.Query <Subscription>() .Where(x => !x.IsDeleted) .Select( x => new SubscriptionDto { Id = x.Id, FullName = x.FullName, EmailAddress = x.EmailAddress, StartDate = x.StartDate, EndDate = x.EndDate }) .OrderBy(x => x.FullName) .ToListAsync()); }
public async Task <IEnumerable <Entities.Subscription> > HandleAsync(GetAllSubscriptionsQuery query) { return(await _repository.GetAsync()); }