Example #1
0
        public async Task <IEnumerable <LocationPreviewModel> > Handle(GetAllLocationsPreviewQuery request,
                                                                       CancellationToken cancellationToken)
        {
            var locationsPreviewList = (await _locationRepository.GetAllLocations()).Select(
                x => new LocationPreviewModel
            {
                Id   = x.Id,
                Name = x.Name
            });

            return(locationsPreviewList);
        }
Example #2
0
        public async Task Ok()
        {
            var query = new GetAllLocationsPreviewQuery();

            var result = await _handler.Handle(query, CancellationToken.None);

            Assert.NotNull(result);
            var resultAsList = result.ToList();

            Assert.Equal(_locations.Count(), resultAsList.Count);
            foreach (var locationPreviewModel in resultAsList)
            {
                var location = _locations.FirstOrDefault(x => x.Id == locationPreviewModel.Id);
                Assert.NotNull(location);
                Assert.Equal(location.Name, locationPreviewModel.Name);
            }
        }