public void Receives_List_Of_CreateDocumentRequests_And_Calls_Repo_To_Save_Accordingly()
        {
            // Given
            var userId = Guid.NewGuid();
            var companyId = 1234;
            var createDocumentRequests = new List<CreateDocumentRequest>();
            var passedRequest = new AddedDocument();
            var createDocumentRequest = new CreateDocumentRequest()
                                            {
                                                Description = "description",
                                                DocumentLibraryId = 1234,
                                                DocumentType = DocumentTypeEnum.GRADocumentType,
                                                Filename = "helloworld.txt",
                                                SiteId = 123,
                                                Title = "title"
                                            };

            _documentRepository.Setup(x => x.SaveOrUpdate(It.IsAny<AddedDocument>())).Callback<Document>(y => passedRequest = y as AddedDocument);

            createDocumentRequests.Add(createDocumentRequest);

            // When
            _target.Add(createDocumentRequests, userId, companyId);

            // Then
            _log.Verify(x => x.Add(It.IsAny<object>()), Times.Once());
            _siteRepository.Verify(x => x.GetById(123), Times.Once());
            _documentTypeRepository.Verify(x => x.GetById(1), Times.Once());
            _userRepository.Verify(x => x.GetByIdAndCompanyId(It.IsAny<Guid>(), It.IsAny<long>()));
            _documentRepository.Verify(x => x.SaveOrUpdate(It.IsAny<AddedDocument>()), Times.Exactly(createDocumentRequests.Count()));

            Assert.That(passedRequest, Is.Not.Null);
            Assert.That(passedRequest.Description, Is.EqualTo(createDocumentRequest.Description));
            Assert.That(passedRequest.DocumentLibraryId, Is.EqualTo(createDocumentRequest.DocumentLibraryId));
            Assert.That(passedRequest.DocumentType, Is.Not.Null);
            Assert.That(passedRequest.Filename, Is.EqualTo(createDocumentRequest.Filename));
            Assert.That(passedRequest.Site, Is.Not.Null);
            Assert.That(passedRequest.Title, Is.EqualTo(createDocumentRequest.Title));
            Assert.That(passedRequest.ClientId, Is.EqualTo(companyId));
        }
 public CompleteRiskAssessmentReviewRequestBuilder WithCreateDocumentRequest(CreateDocumentRequest request)
 {
     _createDocumentRequests.Add(request);
     return this;
 }
        public List<CreateDocumentRequest> MapCreateRequests(FormCollection formCollection)
        {
            var viewModels = CreateNewAddedViewModel(formCollection);
            var requests = new List<CreateDocumentRequest>();

            foreach (var viewModel in viewModels)
            {
                var request = new CreateDocumentRequest
                                  {
                                      DocumentLibraryId = viewModel.DocumentLibraryId,
                                      DocumentType = (DocumentTypeEnum)viewModel.DocumentTypeId,
                                      Title = viewModel.Title,
                                      SiteId = viewModel.SiteId,
                                      Description = viewModel.Description,
                                      Filename = viewModel.Filename,
                                      DocumentOriginType = (DocumentOriginType)viewModel.DocumentOriginTypeId
                                  };

                requests.Add(request);
            }

            return requests;
        }