public void StartTestTestDuplicateDownload()
        {
            var fileUrl = "ABCD";

            repository.Setup(x => x.FindAllUnarchived())
            .Returns(new List <DownloadItem> {
                new DownloadItem {
                    FileUrl = "ABCD"
                }
            });

            var controller = new DownloadItemController(logger.Object, service.Object, authorizationService.Object, repository.Object);
            var response   = controller.Start(fileUrl);

            Assert.AreEqual(400, response.StatusCode);
        }
        public void StartTestTestFailure(int httpCode, DownloadItemActionError error)
        {
            service.Setup(x => x.StartDownload(It.IsAny <DownloadItem>(), out error)).Returns(false);

            var controller = new DownloadItemController(logger.Object, service.Object, authorizationService.Object,
                                                        repository.Object)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = new DefaultHttpContext {
                        User = TestHelper.ItemOwner.MapToClaimPrincipal()
                    }
                }
            };
            var response = controller.Start(It.IsAny <string>());

            Assert.AreEqual(httpCode, response.StatusCode);
        }
        public void StartTestOk()
        {
            var item = new DownloadItem();
            DownloadItemActionError error;

            service.Setup(x => x.StartDownload(item, out error)).Returns(true);
            var controller = new DownloadItemController(logger.Object, service.Object, authorizationService.Object, repository.Object)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = new DefaultHttpContext {
                        User = TestHelper.ItemOwner.MapToClaimPrincipal()
                    }
                }
            };
            var response = controller.Start(It.IsAny <string>());

            Assert.AreEqual(201, response.StatusCode);
        }