public void Download_UserIsAdmin_PermissionsGranted()
        {
            // Arrange
            var serviceMock = GetFinanceServiceMock(false);
            _controller = new ContentController(_unitOfWork, _fileStorageManager, serviceMock.Object);
            _controller.ControllerContext = CreateControllerContext("admin");

            var contentFile = new ContentFile();
            _unitOfWork.GetRepository<ContentFile>().Insert(contentFile);
            _unitOfWork.Save();

            // Act
            var result = _controller.Download(contentFile.ID);

            // Assert
            result.Should().BeOfType<FileStreamResult>();
        }
        public void Download_FileNotExists_ErrorViewShown()
        {
            // Arrange
            var serviceMock = GetFinanceServiceMock();
            _controller = new ContentController(_unitOfWork, _fileStorageManager, serviceMock.Object);
            _controller.ControllerContext = CreateControllerContext();

            // Act
            var result = _controller.Download(-1);

            // Assert
            var viewResult = (ViewResult) result;
            viewResult.ViewName.Should().Be("ApplicationError");
        }
        public void Download_PermissionsNotGranted_ErrorMessageShown()
        {
            // Arrange
            var serviceMock = GetFinanceServiceMock(false);
            _controller = new ContentController(_unitOfWork, _fileStorageManager, serviceMock.Object);
            _controller.ControllerContext = CreateControllerContext();

            var contentFile = new ContentFile();
            _unitOfWork.GetRepository<ContentFile>().Insert(contentFile);

            // Act
            var result = _controller.Download(contentFile.ID);

            // Assert
            var viewResult = (ViewResult) result;
            viewResult.ViewName.Should().Be("ApplicationError");
        }
        public void Download_FileExists_FileStreamReturned()
        {
            // Arrange
            var serviceMock = GetFinanceServiceMock();
            _controller = new ContentController(_unitOfWork, _fileStorageManager, serviceMock.Object);
            _controller.ControllerContext = CreateControllerContext();

            var contentFile = new ContentFile();
            _unitOfWork.GetRepository<ContentFile>().Insert(contentFile);
            _unitOfWork.Save();

            // Act
            _controller.Download(contentFile.ID);

            // Assert
            _fileStorageManager.GetOperationArgument.Should().Be(contentFile);
        }