Beispiel #1
0
        public void TestDeleteDocumentFailsOnMissingDocument()
        {
            Mock <IUserRepository>     mockUserRepository     = new Mock <IUserRepository>();
            Mock <IDocumentRepository> mockDocumentRepository = new Mock <IDocumentRepository>();
            IDocumentManagementService documentLogic          = new DocumentManagementService()
            {
                UserRepository     = mockUserRepository.Object,
                DocumentRepository = mockDocumentRepository.Object
            };
            Guid     fakeId       = Guid.NewGuid();
            Document fakeDocument = new Document
            {
                Id           = fakeId,
                Creator      = GetFakeUser(),
                CreationDate = DateTime.Now.AddDays(-1),
                StyleClass   = new StyleClass()
            };

            mockDocumentRepository
            .Setup(wl => wl.Exists(fakeId))
            .Returns(false);

            documentLogic.Delete(fakeId);

            mockDocumentRepository.VerifyAll();
        }
Beispiel #2
0
 private void InitMocks()
 {
     _dictionary = new Mock <IDictionaryService>();
     _logger     = new Mock <ILogger>();
     _service    = new Mock <IDocumentManagementDataService>();
     _documentManagementService = new DocumentManagementService(_service.Object, _logger.Object, _dictionary.Object);
 }
Beispiel #3
0
        public void TestAddDocumentWorksOnExistingUser()
        {
            Mock <IUserRepository>       mockUserRepository       = new Mock <IUserRepository>();
            Mock <IDocumentRepository>   mockDocumentRepository   = new Mock <IDocumentRepository>();
            Mock <IStyleClassRepository> mockStyleClassRepository = new Mock <IStyleClassRepository>();
            IDocumentManagementService   documentLogic            = new DocumentManagementService()
            {
                UserRepository       = mockUserRepository.Object,
                DocumentRepository   = mockDocumentRepository.Object,
                StyleClassRepository = mockStyleClassRepository.Object
            };
            Document fakeDocument = new Document
            {
                Creator    = GetFakeUser(),
                StyleClass = new StyleClass()
            };
            string userMail = "*****@*****.**";

            mockUserRepository
            .Setup(wl => wl.Exists(userMail))
            .Returns(true);
            mockDocumentRepository
            .Setup(wl => wl.Add(fakeDocument));
            mockStyleClassRepository
            .Setup(wl => wl.Exists(fakeDocument.StyleClass.Name))
            .Returns(true);

            Document result = documentLogic.Add(userMail, fakeDocument);

            mockDocumentRepository.VerifyAll();
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Id);
            Assert.IsTrue(DateTime.Now > result.CreationDate);
        }
Beispiel #4
0
        public void TestGetDocumentByIdWorksOnExistingDocument()
        {
            Mock <IUserRepository>     mockUserRepository     = new Mock <IUserRepository>();
            Mock <IDocumentRepository> mockDocumentRepository = new Mock <IDocumentRepository>();
            IDocumentManagementService documentLogic          = new DocumentManagementService()
            {
                UserRepository     = mockUserRepository.Object,
                DocumentRepository = mockDocumentRepository.Object
            };
            Guid     fakeId       = Guid.NewGuid();
            Document fakeDocument = new Document
            {
                Id         = fakeId,
                Creator    = GetFakeUser(),
                StyleClass = new StyleClass()
            };

            mockDocumentRepository
            .Setup(wl => wl.Exists(fakeId))
            .Returns(true);
            mockDocumentRepository
            .Setup(wl => wl.GetById(fakeId))
            .Returns(fakeDocument);

            Document result = documentLogic.GetById(fakeId);

            mockDocumentRepository.VerifyAll();
            Assert.IsNotNull(result);
            Assert.AreEqual(fakeDocument, result);
        }
Beispiel #5
0
        public void TestGetDocumentByIdFailsOnMissingDocument()
        {
            Mock <IUserRepository>     mockUserRepository     = new Mock <IUserRepository>();
            Mock <IDocumentRepository> mockDocumentRepository = new Mock <IDocumentRepository>();
            IDocumentManagementService documentLogic          = new DocumentManagementService()
            {
                UserRepository     = mockUserRepository.Object,
                DocumentRepository = mockDocumentRepository.Object
            };
            Guid     fakeId       = Guid.NewGuid();
            Document fakeDocument = new Document
            {
                Id         = fakeId,
                Creator    = GetFakeUser(),
                StyleClass = new StyleClass()
            };

            mockDocumentRepository
            .Setup(wl => wl.Exists(fakeId))
            .Returns(false);

            Document result = documentLogic.GetById(fakeId);

            mockDocumentRepository.VerifyAll();
        }
Beispiel #6
0
        public void TestGetDocumentsByUserWorksOnExistingUser()
        {
            Mock <IUserRepository>     mockUserRepository     = new Mock <IUserRepository>();
            Mock <IDocumentRepository> mockDocumentRepository = new Mock <IDocumentRepository>();
            IDocumentManagementService documentLogic          = new DocumentManagementService()
            {
                UserRepository     = mockUserRepository.Object,
                DocumentRepository = mockDocumentRepository.Object
            };
            IEnumerable <Document> fakeDocuments = GetFakeDocuments();
            string userMail = "*****@*****.**";

            mockUserRepository
            .Setup(wl => wl.Exists(userMail))
            .Returns(true);
            mockDocumentRepository
            .Setup(wl => wl.GetAllByUser(userMail))
            .Returns(fakeDocuments);

            IEnumerable <Document> results = documentLogic.GetAllByUser(userMail);

            mockDocumentRepository.VerifyAll();
            Assert.IsNotNull(results);
            Assert.IsTrue(fakeDocuments.SequenceEqual(results));
        }
 public MainViewModel(string benutzername, DocumentManagementService documentManagementService, IMessageBoxService messegaBoxService)
 {
     Benutzer                    = benutzername;
     CmdNavigateToSearch         = new DelegateCommand(OnCmdNavigateToSearch);
     CmdNavigateToDocumentDetail = new DelegateCommand(OnCmdNavigateToDocumentDetail);
     _documentManagementService  = documentManagementService;
     _messegaBoxService          = messegaBoxService;
 }
        public SearchViewModel(DocumentManagementService documentManagementService, IMessageBoxService messegaBoxService)
        {
            TypItems = ComboBoxItems.Typ;

            CmdSuchen  = new DelegateCommand(OnCmdSuchen);
            CmdReset   = new DelegateCommand(OnCmdReset);
            CmdOeffnen = new DelegateCommand(OnCmdOeffnen, OnCanCmdOeffnen);

            _messegaBoxService         = messegaBoxService;
            _documentManagementService = documentManagementService;
        }
        public DocumentDetailViewModel(string benutzer, Action navigateBack, DocumentManagementService documentManagementService, IMessageBoxService messageBoxService)
        {
            _navigateBack   = navigateBack;
            Benutzer        = benutzer;
            Erfassungsdatum = DateTime.Now;
            TypItems        = ComboBoxItems.Typ;

            CmdDurchsuchen = new DelegateCommand(OnCmdDurchsuchen);
            CmdSpeichern   = new DelegateCommand(OnCmdSpeichern);

            _messegaBoxService         = messageBoxService;
            _documentManagementService = documentManagementService;
        }
Beispiel #10
0
 public ActionResult ViewAttachment(string physicalFileName, string fileExtension)
 {
     try
     {
         physicalFileName = physicalFileName + "" + fileExtension;
         return(File(DocumentManagementService.GetFile(physicalFileName), MediaTypeNames.Application.Octet, physicalFileName));
     }
     catch (Exception ex)
     {
         Logging log = new Logging();
         log.LogException(ex);
         return(View("GeneralError"));
     }
 }
Beispiel #11
0
        public ActionResult CreateKnowledgeBaseItem(KnowledgeBase model)
        {
            try
            {
                SiteUser                  siteUser            = (SiteUser)Session["SiteUser"];
                ModelServices             modelService        = new ModelServices();
                List <HttpPostedFileBase> httpPostedFileBases = null;
                if (model.Files.ToList()[0] != null)
                {
                    httpPostedFileBases = model.Files.ToList();
                    var allowedFileSize = ConfigurationManager.AppSettings["FileSize"].ToString();
                    if (!DocumentManagementService.ValidateAttachmentSize(httpPostedFileBases))
                    {
                        ModelState.AddModelError("Files", "Attachment Size exceeds allowed limit of " + allowedFileSize + " MB");
                    }
                }

                if (ModelState.IsValid)
                {
                    var db = new dbTIREntities();
                    KnowledgeBaseService kbService = new KnowledgeBaseService(siteUser, db);

                    if (!kbService.IsKnowledgeBaseExists(model.Title))
                    {
                        //TODO: Till nowwe are picking first district Id. Need to refactor code when a user belongs to more than 1 district.
                        model.DistrictId      = siteUser.Districts[0].Id;
                        model.RoleId          = model.RoleId;
                        model.CreatedDateTime = DateTime.Now;
                        model.CreatedUserId   = siteUser.EdsUserId;
                        model.FileDetails     = model.Files.ToList()[0] != null?DocumentManagementService.GetFileDetail(model.Files) : null;

                        kbService.SaveKnowledgeBase(model);
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("Title", "Duplicate Title - please choose a unique title.");
                    }
                }
                ViewBag.RoleId = new SelectList(modelService.GetRolesForRole((int)(siteUser.Role)), "RoleId", "RoleDesc");
                return(View());
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return(View("GeneralError"));
            }
        }
        public LoginViewModel(LoginView loginView, IMessageBoxService messageBoxService)
        {
            _loginView         = loginView;
            CmdLogin           = new DelegateCommand(OnCmdLogin, OnCanLogin);
            CmdAbbrechen       = new DelegateCommand(OnCmdAbbrechen);
            _messegaBoxService = messageBoxService;

            List <MetadataItem> list          = new List <MetadataItem>();
            IImportService      importService = new ImportService();
            IExportService      exportService = new ExportService();
            IFileService        fileService   = new FileService(_messegaBoxService);
            ISearchService      searchService = new SearchService();

            _documentManagementService = new DocumentManagementService(list, messageBoxService, importService, exportService, fileService, searchService);
            _documentManagementService.RepositoryExists();
        }
Beispiel #13
0
        public void ImportArchiv_execute2_NoException()
        {
            // arrange
            var messegaBoxService = new MessageBoxService();
            var importService     = new ImportServiceForTesting(true);
            var exportService     = new ExportServiceForTesting(true);
            var fileService       = new FileServiceForTesting(true, true, true, true);
            var searchService     = new SearchServiceForTesting(true, true, true);
            var itemlist          = new List <MetadataItem>();
            var DMS = new DocumentManagementService(itemlist, messegaBoxService, importService, exportService, fileService, searchService);

            // act
            void Calculation() => DMS.ImportArchiv();

            // assert
            Assert.DoesNotThrow(Calculation);
        }
Beispiel #14
0
        public void OpenDocument_execute_NoException()
        {
            // arrange
            var messegaBoxService = new MessageBoxServiceForTesting();
            var importService     = new ImportServiceForTesting(false);
            var exportService     = new ExportServiceForTesting(true);
            var fileService       = new FileServiceForTesting(true, true, true, true);
            var searchService     = new SearchServiceForTesting(true, true, true);
            var itemlist          = new List <MetadataItem>();
            var DMS = new DocumentManagementService(itemlist, messegaBoxService, importService, exportService, fileService, searchService);

            // act
            void Calculation() => DMS.OpenDocument(Guid.Parse("3fc6a223-369b-4efd-a0c4-f563ee6d67f8"), 2020, "document.docx");

            // assert
            Assert.DoesNotThrow(Calculation);
        }
Beispiel #15
0
        public void RepositoryExists_CheckRepositoryPath_False()
        {
            // arrange
            ConfigurationManager.AppSettings.Set("RepositoryDir", "C:\\asdfasdfasdfafecdscs\\DMS\\");
            var messegaBoxService = new MessageBoxServiceForTesting();
            var importService     = new ImportServiceForTesting(true);
            var exportService     = new ExportServiceForTesting(true);
            var fileService       = new FileServiceForTesting(true, true, true, false);
            var searchService     = new SearchServiceForTesting(true, true, true);
            var itemlist          = new List <MetadataItem>();
            var DMS = new DocumentManagementService(itemlist, messegaBoxService, importService, exportService, fileService, searchService);

            // act
            var result = DMS.RepositoryExists();

            // assert
            Assert.That(result, Is.EqualTo(false));
        }
Beispiel #16
0
        public void AddNewDocument_RemoveFileFails_True() //True --> Da Messagebox informiert, dass File nicht gelöscht werden konnte
        {
            // arrange
            var messegaBoxService = new MessageBoxServiceForTesting();
            var importService     = new ImportServiceForTesting(true);
            var exportService     = new ExportServiceForTesting(true);
            var fileService       = new FileServiceForTesting(false, true, true, true);
            var searchService     = new SearchServiceForTesting(true, true, true);
            var itemlist          = new List <MetadataItem>();
            var DMS = new DocumentManagementService(itemlist, messegaBoxService, importService, exportService, fileService, searchService);

            // act
            var result = DMS.AddNewDocument("Username", "Dokumenten Bezeichnung", DateTime.Parse("01.01.2020 19:00:00"), "C:\\Temp", "Verträge", "Notiz",
                                            DateTime.Parse("30.06.2020 00:00:00"), true);

            // assert
            Assert.That(result, Is.EqualTo(true));
        }
Beispiel #17
0
        public void RepositoryExists_DeleteBackslashAtTheEndIfExist_StringWithoutBackslash()
        {
            // arrange
            ConfigurationManager.AppSettings.Set("RepositoryDir", "C:\\Temp\\DMS\\");
            var messegaBoxService = new MessageBoxServiceForTesting();
            var importService     = new ImportServiceForTesting(true);
            var exportService     = new ExportServiceForTesting(true);
            var fileService       = new FileServiceForTesting(true, true, true, true);
            var searchService     = new SearchServiceForTesting(true, true, true);
            var itemlist          = new List <MetadataItem>();
            var DMS = new DocumentManagementService(itemlist, messegaBoxService, importService, exportService, fileService, searchService);

            // act
            DMS.RepositoryExists();

            // assert
            Assert.That(ConfigurationManager.AppSettings["RepositoryDir"], Is.EqualTo("C:\\Temp\\DMS"));
        }
Beispiel #18
0
        public void AddNewDocument_MoveFileToRepositoryFails_False()
        {
            // arrange
            var messegaBoxService = new MessageBoxServiceForTesting();
            var importService     = new ImportServiceForTesting(true);
            var exportService     = new ExportServiceForTesting(true);
            var fileService       = new FileServiceForTesting(true, false, true, true);
            var searchService     = new SearchServiceForTesting(true, true, true);
            var itemlist          = new List <MetadataItem>();
            var DMS = new DocumentManagementService(itemlist, messegaBoxService, importService, exportService, fileService, searchService);

            // act
            var result = DMS.AddNewDocument("Username", "Dokumenten Bezeichnung", DateTime.Parse("01.01.2020 19:00:00"), "C:\\Temp", "Verträge", "Notiz",
                                            DateTime.Parse("30.06.2020 00:00:00"), false);

            // assert
            Assert.That(result, Is.EqualTo(false));
        }
        public DroidMessageService()
        {
            Logger.Debug("Started");

            DroidServiceTest.Core.Ioc.Container.Instance.Initialize(cc =>
            {
                cc.RegisterTypeAs <PlatformService, IPlatformService>(true);
            });

            AndroidEnvironment.UnhandledExceptionRaiser += HandleAndroidException;

            _notificationMessages = new List <string>();

            _dms1 = new DocumentManagementService();
            _dms2 = new DocumentManagementService();
            _dms3 = new DocumentManagementService();

            Logger.Debug("Finished");
        }
Beispiel #20
0
        public void TestGetDocumentsByUserThrowsExceptionOnMissingUser()
        {
            Mock <IUserRepository>     mockUserRepository     = new Mock <IUserRepository>();
            Mock <IDocumentRepository> mockDocumentRepository = new Mock <IDocumentRepository>();
            IDocumentManagementService documentLogic          = new DocumentManagementService()
            {
                UserRepository     = mockUserRepository.Object,
                DocumentRepository = mockDocumentRepository.Object
            };
            IEnumerable <Document> fakeDocuments = GetFakeDocuments();
            string userMail = "*****@*****.**";

            mockUserRepository
            .Setup(wl => wl.Exists(userMail))
            .Returns(false);

            IEnumerable <Document> results = documentLogic.GetAllByUser(userMail);

            mockDocumentRepository.VerifyAll();
        }
Beispiel #21
0
        public void SearchDocument__SearchingOfBoth2_False()
        {
            // arrange
            var messegaBoxService = new MessageBoxServiceForTesting();
            var importService     = new ImportServiceForTesting(true);
            var exportService     = new ExportServiceForTesting(true);
            var fileService       = new FileServiceForTesting(true, true, true, true);
            var searchService     = new SearchServiceForTesting(true, true, false);
            var itemlist          = new List <MetadataItem>();

            itemlist.Add(new MetadataItem(Guid.Parse("3fc6a223-369b-4efd-a0c4-f563ee6d67f8"), "Username",
                                          "Dokumenten Bezeichnung", DateTime.Parse("01.01.2020 19:00:00"), "Verträge", "Notiz",
                                          DateTime.Parse("30.06.2020 00:00:00"), "document.docx"));
            var DMS = new DocumentManagementService(itemlist, messegaBoxService, importService, exportService, fileService, searchService);

            // act
            var result = DMS.SearchDocument("AndererText", "Verträge");

            // assert
            Assert.That(result, Is.EqualTo(new List <MetadataItem>()));
        }
Beispiel #22
0
        public void TestUpdateDocumentWorksOnExistingDocument()
        {
            Mock <IUserRepository>       mockUserRepository       = new Mock <IUserRepository>();
            Mock <IDocumentRepository>   mockDocumentRepository   = new Mock <IDocumentRepository>();
            Mock <IStyleClassRepository> mockStyleClassRepository = new Mock <IStyleClassRepository>();
            IDocumentManagementService   documentLogic            = new DocumentManagementService()
            {
                UserRepository       = mockUserRepository.Object,
                DocumentRepository   = mockDocumentRepository.Object,
                StyleClassRepository = mockStyleClassRepository.Object
            };
            Guid     fakeId       = Guid.NewGuid();
            Document fakeDocument = new Document
            {
                Id           = fakeId,
                Creator      = GetFakeUser(),
                CreationDate = DateTime.Now.AddDays(-1),
                StyleClass   = new StyleClass()
            };

            mockDocumentRepository
            .Setup(wl => wl.Exists(fakeId))
            .Returns(true);
            mockDocumentRepository
            .Setup(wl => wl.Update(fakeId, fakeDocument));
            mockStyleClassRepository
            .Setup(wl => wl.Exists(fakeDocument.StyleClass.Name))
            .Returns(true);
            mockDocumentRepository
            .Setup(wl => wl.GetById(fakeId))
            .Returns(fakeDocument);

            documentLogic.Update(fakeId, fakeDocument);

            mockDocumentRepository.VerifyAll();
            Assert.AreNotEqual(fakeDocument.CreationDate, fakeDocument.LastModification);
        }
Beispiel #23
0
        public void TestAddDocumentFailsOnMissingUser()
        {
            Mock <IUserRepository>     mockUserRepository     = new Mock <IUserRepository>();
            Mock <IDocumentRepository> mockDocumentRepository = new Mock <IDocumentRepository>();
            IDocumentManagementService documentLogic          = new DocumentManagementService()
            {
                UserRepository     = mockUserRepository.Object,
                DocumentRepository = mockDocumentRepository.Object
            };
            Document fakeDocument = new Document
            {
                Creator    = GetFakeUser(),
                StyleClass = new StyleClass()
            };
            string userMail = "*****@*****.**";

            mockUserRepository
            .Setup(wl => wl.Exists(userMail))
            .Returns(false);

            Document result = documentLogic.Add(userMail, fakeDocument);

            mockDocumentRepository.VerifyAll();
        }
Beispiel #24
0
 public MainView(string benutzername, DocumentManagementService documentManagementService, IMessageBoxService messegaBoxService)
 {
     InitializeComponent();
     DataContext = new MainViewModel(benutzername, documentManagementService, messegaBoxService);
 }
Beispiel #25
0
 public SearchView(DocumentManagementService documentManagementService, IMessageBoxService messegaBoxService)
 {
     InitializeComponent();
     DataContext = new SearchViewModel(documentManagementService, messegaBoxService);
 }
Beispiel #26
0
 public DocumentDetailView(string benutzer, Action navigateBack, DocumentManagementService documentManagementService, IMessageBoxService messegaBoxService)
 {
     InitializeComponent();
     DataContext = new DocumentDetailViewModel(benutzer, navigateBack, documentManagementService, messegaBoxService);
 }