Esempio n. 1
0
        public async Task <ActionResult> DownloadPhoto(
            [FromRoute] DownloadPhotoQuery query)
        {
            var photo = await Mediator.Send(query);

            return(_fileService.GetFileFromStorage(
                       Path.Combine(_photosDirectory.Users, photo.Path), photo.Name));
        }
Esempio n. 2
0
        public void Handle_GivenInvalidPhotoId_ThrowsException()
        {
            var query = new DownloadPhotoQuery
            {
                PhotoId = 10005
            };

            var handler = GetNewHandler();

            Assert.ThrowsAsync <NotFoundException>(async() =>
                                                   await handler.Handle(query, CancellationToken.None));
        }
Esempio n. 3
0
        public async Task Handle_ShouldBeGetPhoto()
        {
            var query = new DownloadPhotoQuery
            {
                PhotoId = DefaultPhotoIds.First()
            };

            var handler = GetNewHandler();

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

            Assert.That(result.Name, IsNotNullOrEmpty);
            Assert.That(result.Path, IsNotNullOrEmpty);
        }
Esempio n. 4
0
 public UserController(
     CreateUserCommandHandler createCommand,
     GetAllUsersQuery getAllQuery,
     GetUserQuery getOneQuery,
     DownloadPhotoQuery getPhotoQuery,
     SessionQuery sessionQuery,
     UpdateUserCommandHandler updateCommand,
     DeleteUserCommandHandler deleteCommand)
 {
     this.createCommand = createCommand;
     this.getAllQuery   = getAllQuery;
     this.getOneQuery   = getOneQuery;
     this.getPhotoQuery = getPhotoQuery;
     this.sessionQuery  = sessionQuery;
     this.updateCommand = updateCommand;
     this.deleteCommand = deleteCommand;
 }