Example #1
0
        public async Task ShouldGetDocuments_OK()
        {
            // Arrange
            var service   = new Mock <IDocumentService>();
            var logger    = new Mock <ILogger <DocumentController> >();
            var Documents = new List <DocumentDto>()
            {
                new DocumentDto()
                {
                    DocumentId = Guid.NewGuid(), CreatedSubject = new SubjectDto(), LastModifiedSubject = new SubjectDto()
                },
            };

            service.Setup(repo => repo.GetDocuments(null)).ReturnsAsync(Documents);
            var controller = new DocumentController(logger.Object, service.Object);

            // Act
            var result = await controller.GetDocuments();

            // Assert
            var viewResult = Assert.IsAssignableFrom <OkObjectResult>(result);
            var model      = Assert.IsAssignableFrom <List <DocumentModel> >(viewResult.Value);

            Assert.Single(model);
        }
 public void InitializeDocumentWithoutSerialization()
 {
     docControl = new DocumentController();
     docControl.InitializeDocuments();
     docControl.CalculateDocumentsDeviation();
     CreateNodes();
 }
        public async void Patch_No_Errors()
        {
            DocumentControllerMockFacade mock = new DocumentControllerMockFacade();
            var mockResult = new Mock <UpdateResponse <ApiDocumentResponseModel> >();

            mockResult.SetupGet(x => x.Success).Returns(true);
            mock.ServiceMock.Setup(x => x.Update(It.IsAny <Guid>(), It.IsAny <ApiDocumentRequestModel>()))
            .Callback <Guid, ApiDocumentRequestModel>(
                (id, model) => model.ChangeNumber.Should().Be(1)
                )
            .Returns(Task.FromResult <UpdateResponse <ApiDocumentResponseModel> >(mockResult.Object));
            mock.ServiceMock.Setup(x => x.Get(It.IsAny <Guid>())).Returns(Task.FromResult <ApiDocumentResponseModel>(new ApiDocumentResponseModel()));
            DocumentController controller = new DocumentController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, new ApiDocumentModelMapper());

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var patch = new JsonPatchDocument <ApiDocumentRequestModel>();

            patch.Replace(x => x.ChangeNumber, 1);

            IActionResult response = await controller.Patch(default(Guid), patch);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            mock.ServiceMock.Verify(x => x.Update(It.IsAny <Guid>(), It.IsAny <ApiDocumentRequestModel>()));
        }
        public void GivenADocumentThatHasNotBeenApproved_WhenIAskForStatus_ThenIGetTheCorrectView()
        {
            _controller = new DocumentController(
                _documentService.Object,
                _userService.Object,
                _manCoService.Object,
                _logger.Object);

            _documentService.Setup(d => d.GetDocument("1")).Returns(new Document()
            {
                GridRun = new GridRun
                {
                    XmlFile = new XmlFile
                    {
                        Received = DateTime.Now.AddDays(-1)
                    },
                    EndDate = DateTime.Now.AddHours(-1)
                }
            });

            var result = (PartialViewResult)_controller.Status("1");
            var model  = (DocumentStatusViewModel)result.Model;

            model.Approved.Should().BeNull();
            result.ViewName.Should().Be("_DocumentStatus");
        }
Example #5
0
        public void AddDocument_ReturnCreateItem_WhenModelModelValid()
        {
            //Arrange
            var dbContext = new DocumentDbContext();

            dbContext.Categories = GetQueryableMockDbSetCategory();
            dbContext.Documents  = GetQueryableMockDbSetDocument();

            var categoryRepo = new CategoryRepo(string.Empty, dbContext);
            var documentRepo = new DocumentRepo(string.Empty, dbContext);
            var controller   = new DocumentController(categoryRepo, documentRepo);

            AddDocumentModel addDocumentModel = new AddDocumentModel {
                Title = "Đời sống con người", Description = "Nói về đời sống con người", CategoryId = 1, Cover = "", PublishYear = 2013
            };
            //Act
            var result = controller.AddDocument(addDocumentModel);

            //Assert
            Assert.IsType <OkObjectResult>(result);

            var okObjectResult = result as OkObjectResult;

            Assert.IsType <Document>(okObjectResult.Value);

            var model = okObjectResult.Value as Document;

            Assert.Equal(model.Title, addDocumentModel.Title);
            Assert.Equal(model.Description, addDocumentModel.Description);
            Assert.Equal(model.CategoryId, addDocumentModel.CategoryId);
            Assert.Equal(model.Cover, addDocumentModel.Cover);
            Assert.Equal(model.PublishYear, addDocumentModel.PublishYear);
        }
Example #6
0
        public override async Task <bool> SupportsController(DocumentController controller)
        {
            if (!(controller is FileDocumentController fileController) || !IdeApp.IsInitialized)
            {
                return(false);
            }

            project = controller.Owner;
            if (project == null)
            {
                // Fix for broken .csproj and .sln files not being seen as having a project.
                foreach (var projItem in Ide.IdeApp.Workspace.GetAllItems <UnknownSolutionItem> ())
                {
                    if (projItem.FileName == fileController.FilePath)
                    {
                        project = projItem;
                    }
                }

                if (project == null)
                {
                    return(false);
                }
            }

            repo = VersionControlService.GetRepository(project);
            if (repo == null)
            {
                return(false);
            }

            return(true);
        }
Example #7
0
        public Response DeleteRequiredAction(string ActionId, string Path)
        {
            try
            {
                try
                {
                    DocumentController dc = new DocumentController();
                    dc.DeleteImage(Path, ActionId, "true");
                }
                catch
                {
                    new RequiredActionsBL().DeleteImage(ActionId);
                }

                return(new Response()
                {
                    Message = "Action Deleted Successfully",
                    Status = "200",
                    Value = true
                });
            }
            catch (Exception ex)
            {
                return(new Response()
                {
                    Message = ex.Message,
                    Status = "400",
                    Value = false
                });
            }
        }
 public VersionControlDocumentInfo(VersionControlDocumentController versionControlExtension, DocumentController controller, VersionControlItem item, Repository repository)
 {
     this.VersionControlExtension = versionControlExtension;
     Controller      = controller;
     this.Item       = item;
     item.Repository = repository;
 }
Example #9
0
        public void Upload_FileUploaded_ShouldReturnCreatedResult()
        {
            var pdf = new PdfDocument
            {
                Doc = Substitute.For <IFormFile>()
            };

            using var ms = new MemoryStream();
            var writer = new StreamWriter(ms);

            writer.Write("Test File");
            writer.Flush();
            ms.Position = 0;

            pdf.Doc.OpenReadStream().Returns(ms);
            pdf.Doc.FileName.Returns("Test.pdf");
            pdf.Doc.Length.Returns(ms.Length);

            var service = Substitute.For <IStorageService>();

            service.UploadFile(Arg.Any <Stream>()).Returns(Guid.NewGuid().ToString());
            var docController = new DocumentController(Substitute.For <IRepository>(), service, Substitute.For <IMapper>());

            var result = docController.Upload(pdf);

            Assert.IsType <CreatedResult>(result.Result);
        }
Example #10
0
        public void TestDocumentControllerIndex()
        {
            var documentController = new DocumentController();
            var resultat           = documentController.Index("", "", 0) as ViewResult;

            Assert.AreEqual("", resultat.ViewName);
        }
Example #11
0
        public void Download_RecordFoundForLocation_FilePresent_ShouldReturnPdfFile()
        {
            var docRepo = Substitute.For <IRepository>();
            var docs    = new List <Document>();

            docs.Add(new Document
            {
                DocId        = "2b4e176c-3608-4a7f-8aef-1eb25d6f531c",
                FileSize     = 556796,
                Name         = "Test.pdf",
                Location     = "https://sjchambers.blob.core.windows.net/sjchambers/2b4e176c-3608-4a7f-8aef-1eb25d6f531c",
                DisplayOrder = 1
            });
            docRepo.GetDocs().Returns(docs);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DocumentMapper());
            });
            var mapper = config.CreateMapper();

            var docController = new DocumentController(docRepo, Substitute.For <IStorageService>(), mapper);

            var result = docController.Download(HttpUtility.UrlEncode(docs[0].Location));

            Assert.IsType <FileContentResult>(result);

            Assert.Equal("application/pdf", ((FileContentResult)result).ContentType);
        }
Example #12
0
        public void Upload_FailedToUpload_ShouldReturnInternalServerError()
        {
            var pdf = new PdfDocument
            {
                Doc = Substitute.For <IFormFile>()
            };

            using var ms = new MemoryStream();
            var writer = new StreamWriter(ms);

            writer.Write("Test File");
            writer.Flush();
            ms.Position = 0;

            pdf.Doc.OpenReadStream().Returns(ms);
            pdf.Doc.FileName.Returns("Test.pdf");
            pdf.Doc.Length.Returns(ms.Length);

            var service = Substitute.For <IStorageService>();

            service.UploadFile(Arg.Any <Stream>()).Returns(Guid.Empty.ToString());
            var docController = new DocumentController(Substitute.For <IRepository>(), service, Substitute.For <IMapper>());

            var result = docController.Upload(pdf);

            Assert.Equal(StatusCodes.Status500InternalServerError, ((ObjectResult)result.Result).StatusCode);
        }
Example #13
0
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();

        m_DocumentController  = new DocumentController(new GtkWarningViewHelper(warningsScrolledWindow, warningsTreeView), new FileSystem(), new FileDialogHelper(), new GtkTextViewHelper(this.codeTextview), new Document());
        m_GeneratorController = new GeneratorController(new FileSystem(), new GtkResultViewHelper(resultsTreeview), new ClipBoardHelper(), new GtkTextViewHelper(this.detailsTextview));
    }
Example #14
0
        public void DeleteDocument_ReturnsOK()
        {
            // Arrange
            var id                  = 123;
            var documentTitle       = "dokument";
            var categoryId          = 123;
            var caseId              = 123;
            var documentDescription = "description";
            var documentPath        = "path";
            var documentContent     = "content";

            var document = new CreateDocumentDto()
            {
                DocumentId          = id,
                CaseId              = caseId,
                DocumentTitle       = documentTitle,
                CategoryId          = categoryId,
                DocumentDescription = documentDescription,
                DocumentPath        = documentPath,
                DocumentContent     = documentContent
            };

            var documentRepo = new Mock <IDocumentRepository>();

            documentRepo.Setup(x => x.SaveDocument(document));
            var documentManipulation = new DocumentManipulation(documentRepo.Object);
            var logger     = new Mock <Microsoft.Extensions.Logging.ILogger <DocumentController> >().Object;
            var controller = new DocumentController(documentManipulation, logger);
            // Act
            var result = controller.Delete(id);

            // Assert
            Assert.IsInstanceOfType(result, typeof(OkObjectResult));
        }
        public void GetFormalProposalWithValidOpportunity_ThenOkIsReturned()
        {
            var documentData = JsonConvert.SerializeObject(new OpportunityViewModel()
            {
                Id          = "1",
                DisplayName = "Display Name"
            }, new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK)
            {
                Content = new StringContent(documentData)
            };

            var mockGraphHelper = GetGraphSdkHelper(response).Object;

            var mockHttpClient = new HttpClient(new MockHttpMessageHandler(response));

            var controller = new DocumentController(mockGraphHelper, ConfigurationProvider);
            var result     = controller.GetFormalProposalAsync("id").GetAwaiter().GetResult() as OkObjectResult;

            Assert.IsNotNull(result);
            StringAssert.Equals(documentData, result.Value.ToString());
        }
Example #16
0
        public void Post_ShouldReturnDocument()
        {
            // Arrange
            DocumentController docController = new DocumentController();

            docController.Request = new HttpRequestMessage()
            {
                Properties = { { HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration() } }
            };

            DocumentRequest docRequest = new DocumentRequest();

            docRequest.Region          = "AF";
            docRequest.BusinessSegment = "D";
            docRequest.BusinessUnit    = "M";
            docRequest.Client          = "Nedbank";
            docRequest.DocType         = "B0004";
            docRequest.RefNo           = "0520160713095416112";



            HttpResponseMessage response = docController.Post(docRequest);

            Document doc = (Document)((System.Net.Http.ObjectContent)(response.Content)).Value;

            if (doc.IsSuccessful)
            {
                Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            }
            else
            {
                Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
            }
        }
        public async Task ValidateNumberOfDocunents()
        {
            // Arrange
            var mockRepository = new Mock <IDocumentRepository>(MockBehavior.Strict);

            mockRepository.Setup(m => m.GetUserDocuments(1))
            .ReturnsAsync(new List <DocumentEntity>
            {
                new DocumentEntity
                {
                    Id      = Guid.NewGuid(),
                    Link    = string.Empty,
                    UserId  = 1,
                    Name    = string.Empty,
                    Created = DateTime.UtcNow.AddDays(-1),
                }
            });

            var controller = new DocumentController(mockRepository.Object);

            // Act
            var actionResult  = controller.GetUserDocuments(1);
            var contentResult = await actionResult as OkNegotiatedContentResult <string>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            var documents = JsonConvert.DeserializeObject <IEnumerable <object> >(contentResult.Content);

            Assert.AreEqual(documents.Count(), 1);

            mockRepository.Verify(x => x.GetUserDocuments(1), Times.Once);
        }
        /// <summary>
        /// Initialize all documents
        /// </summary>
        public async void Init(int width, int height)
        {
            //Initialize controllers
            documentController        = new DocumentController(this);
            cardController            = new CardController(this);
            sortingBoxController      = new SortingBoxController(this);
            touchController           = new TouchController(this);
            gestureController         = new GestureController(this);
            listenerController        = new GestureListenerController(this);
            baseLayerController       = new BaseLayerController(this);
            cardLayerController       = new CardLayerController(this);
            sortingBoxLayerController = new SortingBoxLayerController(this);
            menuLayerController       = new MenuLayerController(this);
            //Initialize layers
            touchController.Init();
            gestureController.Init();
            listenerController.Init();
            baseLayerController.Init(width, height);
            Coordination.Baselayer = baseLayerController.BaseLayer;//Set the base layer to the coordination helper
            cardLayerController.Init(width, height);
            sortingBoxLayerController.Init(width, height);
            menuLayerController.Init(width, height);
            //Load the documents, cards and add them to the card layer
            Document[] docs = await documentController.Init(FilePath.NewsArticle);//Load the document

            Card[] cards = await cardController.Init(docs);

            CardLayerController.LoadCards(cards);
            //Load the sorting box and add them to the sorting box layer
            sortingBoxController.Init();
            SortingBoxLayerController.LoadBoxes(sortingBoxController.GetAllSortingBoxes());
            //Start the gesture detection thread
            gestureController.StartGestureDetection();
        }
Example #19
0
        public void AddWeakEventListenerTest() 
        {
            // Add a weak event listener and check if the eventhandler is called
            DocumentManager documentManager = new DocumentManager();
            DocumentController controller = new DocumentController(documentManager);
            Assert.IsFalse(controller.DocumentsHasChanged);
            Assert.IsFalse(controller.ActiveDocumentHasChanged);
            documentManager.Open();
            Assert.IsTrue(controller.DocumentsHasChanged);
            Assert.IsTrue(controller.ActiveDocumentHasChanged);

            // Remove the weak event listener and check that the eventhandler is not anymore called
            controller.RemoveWeakEventListeners();
            controller.DocumentsHasChanged = false;
            controller.ActiveDocumentHasChanged = false;
            documentManager.Open();
            Assert.IsFalse(controller.DocumentsHasChanged);
            Assert.IsFalse(controller.ActiveDocumentHasChanged);

            // Remove again the same weak event listeners although they are not anymore registered
            controller.RemoveWeakEventListeners();

            // Check that the garbage collector is able to collect the controller although the service lives longer
            controller.AddWeakEventListeners();
            documentManager.Open();
            Assert.IsTrue(controller.DocumentsHasChanged);
            Assert.IsTrue(controller.ActiveDocumentHasChanged);
            WeakReference weakController = new WeakReference(controller);
            controller = null;
            GC.Collect();

            Assert.IsFalse(weakController.IsAlive);
        }
Example #20
0
        public void TestDocumentControllerDetails()
        {
            var documentController = new DocumentController();
            var resultat           = documentController.Modifier(1) as ViewResult;

            Assert.AreEqual("", resultat.ViewName);
        }
        public void GivenADocumentController_WhenICallItsSearchGridMethod_WithAnAjaxRequest_ThenIGetTHeCorrectViewReturned()
        {
            var controller = new DocumentController(
                _documentService.Object,
                _userService.Object,
                _manCoService.Object,
                _logger.Object);

            _documentService.Setup(d => d.GetDocuments(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>())).Returns(_documentsIndexed);
            _documentService.Setup(d => d.GetDocuments(It.IsAny <String>())).Returns(new List <Document>()
            {
                new Document()
            });
            _documentService.Setup(d => d.GetUnApprovedDocuments(It.IsAny <String>())).Returns(new List <Document>()
            {
                new Document()
            });
            _documentService.Setup(d => d.GetApprovedDocuments(It.IsAny <String>())).Returns(new List <Document>()
            {
                new Document()
            });

            var result = (PartialViewResult)controller.SearchGrid(It.IsAny <string>(), It.IsAny <int>(), true);

            result.Model.Should().BeOfType <DocumentsViewModel>();
            result.ViewName.Should().Be("_PagedDocumentResults");
        }
        public async Task SignDocument_DocumentIdIsNull_ThrowsApiArgumentNullException()
        {
            DocumentController controller = new DocumentController(documentService.Object, authorizationService.Object);
            Signature          signature  = new Mock <Signature>().Object;

            ActionResult <Signature> result = await controller.SignDocumentAsync(null !, signature);
        }
Example #23
0
        public void AddWeakEventListenerTest()
        {
            // Add a weak event listener and check if the eventhandler is called
            DocumentManager    documentManager = new DocumentManager();
            DocumentController controller      = new DocumentController(documentManager);

            Assert.IsFalse(controller.DocumentsHasChanged);
            Assert.IsFalse(controller.ActiveDocumentHasChanged);
            documentManager.Open();
            Assert.IsTrue(controller.DocumentsHasChanged);
            Assert.IsTrue(controller.ActiveDocumentHasChanged);

            // Remove the weak event listener and check that the eventhandler is not anymore called
            controller.RemoveWeakEventListeners();
            controller.DocumentsHasChanged      = false;
            controller.ActiveDocumentHasChanged = false;
            documentManager.Open();
            Assert.IsFalse(controller.DocumentsHasChanged);
            Assert.IsFalse(controller.ActiveDocumentHasChanged);

            // Remove again the same weak event listeners although they are not anymore registered
            controller.RemoveWeakEventListeners();

            // Check that the garbage collector is able to collect the controller although the service lives longer
            controller.AddWeakEventListeners();
            documentManager.Open();
            Assert.IsTrue(controller.DocumentsHasChanged);
            Assert.IsTrue(controller.ActiveDocumentHasChanged);
            WeakReference weakController = new WeakReference(controller);

            controller = null;
            GC.Collect();

            Assert.IsFalse(weakController.IsAlive);
        }
Example #24
0
        public void RemoveDocument_ReturnRemovedItem_WhenDocumentExist()
        {
            //Arrange
            var dbContext = new DocumentDbContext();

            dbContext.Categories = GetQueryableMockDbSetCategory();
            dbContext.Documents  = GetQueryableMockDbSetDocument();

            var categoryRepo = new CategoryRepo(string.Empty, dbContext);
            var documentRepo = new DocumentRepo(string.Empty, dbContext);
            var controller   = new DocumentController(categoryRepo, documentRepo);

            int testDocumentId = 1;

            //Act
            var result = controller.RemoveDocument(testDocumentId);

            //Assert
            Assert.IsType <OkObjectResult>(result);

            var okObjectResult = result as OkObjectResult;

            Assert.IsType <Document>(okObjectResult.Value);

            var documentObject = okObjectResult.Value as Document;

            Assert.Equal(documentObject.Id, testDocumentId);
        }
Example #25
0
        public void ArgumentNullTest()
        {
            DocumentManager    documentManager = new DocumentManager();
            DocumentController controller      = new DocumentController(documentManager);
            ShellViewModel     shellViewModel  = new ShellViewModel(new MockView(), documentManager);

            AssertHelper.ExpectedException <ArgumentNullException>(() => controller.AddWeakEventListener((INotifyPropertyChanged)null, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => controller.AddWeakEventListener(documentManager, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => controller.RemoveWeakEventListener((INotifyPropertyChanged)null, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => controller.RemoveWeakEventListener(documentManager, null));

            AssertHelper.ExpectedException <ArgumentNullException>(() => controller.AddWeakEventListener((INotifyCollectionChanged)null, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => controller.AddWeakEventListener((INotifyCollectionChanged)documentManager.Documents, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => controller.RemoveWeakEventListener((INotifyCollectionChanged)null, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => controller.RemoveWeakEventListener((INotifyCollectionChanged)documentManager.Documents, null));

            AssertHelper.ExpectedException <ArgumentNullException>(() => shellViewModel.AddWeakEventListener((INotifyPropertyChanged)null, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => shellViewModel.AddWeakEventListener(documentManager, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => shellViewModel.RemoveWeakEventListener((INotifyPropertyChanged)null, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => shellViewModel.RemoveWeakEventListener(documentManager, null));

            AssertHelper.ExpectedException <ArgumentNullException>(() => shellViewModel.AddWeakEventListener((INotifyCollectionChanged)null, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => shellViewModel.AddWeakEventListener((INotifyCollectionChanged)documentManager.Documents, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => shellViewModel.RemoveWeakEventListener((INotifyCollectionChanged)null, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => shellViewModel.RemoveWeakEventListener((INotifyCollectionChanged)documentManager.Documents, null));

            AssertHelper.ExpectedException <ArgumentNullException>(() => new PropertyChangedEventListener(null, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => new PropertyChangedEventListener(documentManager, null));

            AssertHelper.ExpectedException <ArgumentNullException>(() => new CollectionChangedEventListener(null, null));
            AssertHelper.ExpectedException <ArgumentNullException>(() => new CollectionChangedEventListener((INotifyCollectionChanged)documentManager.Documents, null));
        }
Example #26
0
        public async Task DocumentController_GetDocumentsAsync_ReturnsExpectedDocuments()
        {
            var document = new Document {
                DocumentType = "Leasing", Id = Guid.Empty, OwnerId = "001"
            };
            IList <Document> documents = new List <Document> {
                document
            };

            documentService.Setup(ds => ds.GetDocumentsAsync(It.IsAny <string>()))
            .ReturnsAsync(documents);

            var documentController = new DocumentController(documentService.Object, authorizationService.Object);

            documentController.ControllerContext.HttpContext = new DefaultHttpContext()
            {
            };

            ActionResult <Document[]>?actionResult = await documentController.GetDocumentsAsync();

            var result = (actionResult.Result as OkObjectResult);

            Assert.IsNotNull(result);
            var returnedDocuments = result.Value as IList <Document>;

            Assert.IsTrue(returnedDocuments.SequenceEqual(documents));
        }
Example #27
0
        public async Task <string> GetCollections([FromBody] JToken body)
        {
            var docController = new DocumentController();
            await docController.POST(body.ToString());

            return(await docController.Get());
        }
        public async void BulkInsert_No_Errors()
        {
            DocumentControllerMockFacade mock = new DocumentControllerMockFacade();

            var mockResponse = new CreateResponse <ApiDocumentResponseModel>(new FluentValidation.Results.ValidationResult());

            mockResponse.SetRecord(new ApiDocumentResponseModel());
            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiDocumentRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiDocumentResponseModel> >(mockResponse));
            DocumentController controller = new DocumentController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var records = new List <ApiDocumentRequestModel>();

            records.Add(new ApiDocumentRequestModel());
            IActionResult response = await controller.BulkInsert(records);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var result = (response as OkObjectResult).Value as List <ApiDocumentResponseModel>;

            result.Should().NotBeEmpty();
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiDocumentRequestModel>()));
        }
Example #29
0
        public async Task return_400_for_invalid_photo_request(string propertyId)
        {
            controller = SetupControllerWithSimpleService();
            var response = await controller.GetPhotoByPropertyId(propertyId);

            Assert.Equal((int)HttpStatusCode.BadRequest, response.StatusCode);
        }
        public void GivenADocumentController_WhenICallItsSearchGridMethod_ThenItRetrunsTheCorrectNumberOfDocuments()
        {
            var controller = new DocumentController(
                _documentService.Object,
                _userService.Object,
                _manCoService.Object,
                _logger.Object);

            _documentService.Setup(d => d.GetDocuments(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>())).Returns(_documentsIndexed);
            _documentService.Setup(d => d.GetDocuments(It.IsAny <String>())).Returns(new List <Document>()
            {
                new Document()
            });
            _documentService.Setup(d => d.GetUnApprovedDocuments(It.IsAny <String>())).Returns(new List <Document>()
            {
                new Document()
            });
            _documentService.Setup(d => d.GetApprovedDocuments(It.IsAny <String>())).Returns(new List <Document>()
            {
                new Document()
            });

            var result = (ViewResult)controller.SearchGrid(It.IsAny <string>());
            var model  = (DocumentsViewModel)result.Model;

            int documentCount = (from s in _documentsIndexed.Results select s).Count();

            model.Documents.Should().HaveCount(documentCount);
        }
Example #31
0
        public async Task return_400_for_invalid_request_on_document_functions(string fileId)
        {
            controller = SetupControllerWithFakeSimpleService();
            var response = (JsonResult) await PickDocumentControllerEndpoint(randomPick, fileId);

            Assert.Equal((int)HttpStatusCode.BadRequest, response.StatusCode);
        }
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.documentController1 = new TXTextControl.DocumentServer.DocumentController(this.components);
            this.serverTextControl1 = new TXTextControl.ServerTextControl();
            // 
            // documentController1
            // 
            this.documentController1.TextComponent = this.serverTextControl1;
            // 
            // serverTextControl1
            // 
            this.serverTextControl1.SpellChecker = null;

        }
Example #33
0
        public void ArgumentNullTest()
        {
            DocumentManager documentManager = new DocumentManager();
            DocumentController controller = new DocumentController(documentManager);
            ShellViewModel shellViewModel = new ShellViewModel(new MockView(), documentManager);
            
            AssertHelper.ExpectedException<ArgumentNullException>(() => controller.AddWeakEventListener((INotifyPropertyChanged)null, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => controller.AddWeakEventListener(documentManager, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => controller.RemoveWeakEventListener((INotifyPropertyChanged)null, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => controller.RemoveWeakEventListener(documentManager, null));

            AssertHelper.ExpectedException<ArgumentNullException>(() => controller.AddWeakEventListener((INotifyCollectionChanged)null, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => controller.AddWeakEventListener((INotifyCollectionChanged)documentManager.Documents, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => controller.RemoveWeakEventListener((INotifyCollectionChanged)null, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => controller.RemoveWeakEventListener((INotifyCollectionChanged)documentManager.Documents, null));

            AssertHelper.ExpectedException<ArgumentNullException>(() => shellViewModel.AddWeakEventListener((INotifyPropertyChanged)null, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => shellViewModel.AddWeakEventListener(documentManager, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => shellViewModel.RemoveWeakEventListener((INotifyPropertyChanged)null, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => shellViewModel.RemoveWeakEventListener(documentManager, null));

            AssertHelper.ExpectedException<ArgumentNullException>(() => shellViewModel.AddWeakEventListener((INotifyCollectionChanged)null, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => shellViewModel.AddWeakEventListener((INotifyCollectionChanged)documentManager.Documents, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => shellViewModel.RemoveWeakEventListener((INotifyCollectionChanged)null, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => shellViewModel.RemoveWeakEventListener((INotifyCollectionChanged)documentManager.Documents, null));

            AssertHelper.ExpectedException<ArgumentNullException>(() => new PropertyChangedEventListener(null, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => new PropertyChangedEventListener(documentManager, null));

            AssertHelper.ExpectedException<ArgumentNullException>(() => new CollectionChangedEventListener(null, null));
            AssertHelper.ExpectedException<ArgumentNullException>(() => new CollectionChangedEventListener((INotifyCollectionChanged)documentManager.Documents, null));
        }
 public AlarmRuleSetController()
 {
     _dbConnStr = DataProvider.GetConnectionString();
     _docCtrl = new DocumentController(_dbConnStr);
     _branchCtrl = new BranchController(_dbConnStr);
 }
 public ApplyContainerController()
 {
     _dbConnStr = DataProvider.GetConnectionString();
     _docCtrl = new DocumentController(_dbConnStr);
     _branchCtrl = new BranchController(_dbConnStr);
 }