Exemplo n.º 1
0
        public void Given_get_Then_should_return_correct_view_model()
        {
            //Given
            var controller = CreateAddedDocumentsLibraryController();


            var returnedViewModel = new AddedDocumentsLibraryViewModel();
            _viewModelFactory.Setup(x => x.GetViewModel()).Returns(returnedViewModel);

            //Get
            var result = controller.Index(_documentTypeId, _siteId, _siteGroupId, _title) as ViewResult;
            
            //Then
            Assert.That(result.Model, Is.InstanceOf<AddedDocumentsLibraryViewModel>());
        }
        public void Given_a_user_with_delete_added_documents_permissions_and_task_is_not_an_added_document_When_IsDeleteEnabled_Then_returns_false
            ()
        {
            //Given
            var target = new AddedDocumentsLibraryViewModel();
            var user = new Mock<IPrincipal>();
            user.Setup(x => x.IsInRole(It.IsAny<string>())).Returns(true);

            var addedDocumentDto = new TaskDocumentDto()
            {
                DocumentType = new DocumentTypeDto(),
                CreatedOn = DateTime.Now
            };
            var viewModel = DocumentViewModel.CreateFrom(addedDocumentDto);

            //When
            var result = target.IsDeleteDocumentEnabled(user.Object, viewModel);

            //Then
            Assert.IsFalse(result);
        }