Beispiel #1
0
        public void TestShouldThrowEmptyExtension()
        {
            //Arrange
            string fileName = "tests\\testEmptyExtension";

            //Act

            try
            {
                FileContentProvider provider = new FileContentProvider();
                var file = (content : provider.GetContent(fileName), extension : Path.GetExtension(fileName));

                FileProcessorFactory fileProcessorFactory = new FileProcessorFactory();
                var fileProcessor = fileProcessorFactory.CreateFileProcessor(file.content, file.extension);
                fileProcessor.Process(file.content);
            }
            catch (System.ArgumentException e)
            {
                // Assert
                StringAssert.Contains(e.Message, FileProcessorFactory.EmptyExtensionMessage);
                return;
            }

            Assert.Fail("The expected exception was not thrown.");
        }
Beispiel #2
0
        /// <summary>
        /// Begins the work.
        /// </summary>
        protected override void BeginWork()
        {
            base.BeginWork();

            try
            {
                m_Parameters = DocumentImportHelper.GetProfileBeo((string)BootParameters);

                m_CounterForCorrelationId = 0;

                InitializeConfigurationItems();

                //?? need to percentage completion
                m_PercenatgeCompletion = 100;

                m_Documents = new List <RVWDocumentBEO>();

                #region Get Dataset Details
                if (m_Parameters != null && m_Parameters.DatasetDetails.FolderID > 0)
                {
                    m_FileProcessor = FileProcessorFactory.CreateFileProcessor(
                        FileProcessorFactory.ExtractionChoices.CompoundFileExtraction);
                    m_Dataset = DataSetBO.GetDataSetDetailForDataSetId(m_Parameters.DatasetDetails.FolderID);

                    if (m_Dataset.Matter != null && m_Dataset.Matter.FolderID > 0)
                    {
                        var matterDetails = MatterDAO.GetMatterDetails(m_Dataset.Matter.FolderID.ToString());
                        if (matterDetails != null)
                        {
                            m_Dataset.Matter = matterDetails;
                            var searchServerDetails = ServerDAO.GetSearchServer(matterDetails.SearchServer.Id);
                            if (searchServerDetails != null)
                            {
                                m_Dataset.Matter.SearchServer = searchServerDetails;
                            }
                        }
                    }
                    else
                    {
                        throw new EVException().AddErrorCode(ErrorCodes.EDLoaderExtractionWorker_FailedToObtainMatterDetails); //?? need to set message in resource file
                    }
                }
                else
                {
                    throw new EVException().AddErrorCode(ErrorCodes.EDLoaderExtractionWorker_ObtainDatasetDetailsFailure); //?? need to set message in resource file
                }
                #endregion
            }
            catch (Exception ex)
            {
                ex.Trace().Swallow();
            }
        }
Beispiel #3
0
        public void TestTextFile()
        {
            //Arrange
            string fileName = "tests\\testText.txt";
            string expected = "text";

            //Act
            FileContentProvider provider = new FileContentProvider();
            var file = (content : provider.GetContent(fileName), extension : Path.GetExtension(fileName));

            FileProcessorFactory fileProcessorFactory = new FileProcessorFactory();
            var fileProcessor = fileProcessorFactory.CreateFileProcessor(file.content, file.extension);

            fileProcessor.Process(file.content);

            //Assert
            string actual = fileProcessor.ReturnType();

            Assert.AreEqual(expected, actual, "Wrong type (expected:" + expected);
        }