예제 #1
0
        public bool ConvertFormat(string sourceFileName, string targetFileName)
        {
            string input;

            try
            {
                var inputRetriever = InputRetriever.ForFileName(sourceFileName);
                input = inputRetriever.GetData(sourceFileName);
            }
            catch (FileNotFoundException)
            {
                return(false);
            }

            var doc           = _inputParser.ParseInput(input);
            var serializedDoc = _documentSerializer.Serialize(doc);

            try
            {
                var documentPersister = DocumentPersister.ForFileName(targetFileName);
                documentPersister.PersistDocument(serializedDoc, targetFileName);
            }
            catch (AccessViolationException)
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        private static void ConfigureStorage()
        {
            var blobStorage        = new BlobDocumentStorage(ConfigurationManager.AppSettings["storageAccount"], ConfigurationManager.AppSettings["storageKey"]);
            var fileStorage        = new FileDocumentStorage();
            var httpInputRetriever = new HttpInputRetriever();

            InputRetriever.RegisterInputRetriever(x => x.StartsWith("http"), httpInputRetriever);
            InputRetriever.RegisterInputRetriever(IsBlobstorageUrl, blobStorage);
            InputRetriever.RegisterInputRetriever(x => true, fileStorage);
            DocumentPersister.RegisterDocumentPersister(IsBlobstorageUrl, blobStorage);
            DocumentPersister.RegisterDocumentPersister(x => true, fileStorage);
        }
        public void verify_modification_of_state()
        {
            // arrange
            var mockContext = new Mock<IDocumentContext>();
            mockContext.Setup(e => e.SetState(It.Is<WorkflowState>(p => p == WorkflowState.UnderReview)));
            mockContext.Setup(e => e.Save());

            var item = new DocumentPersister();

            // act
            item.ExecuteWithContext(WorkflowState.Create,
                                    WorkflowState.UnderReview,
                                    StateTrigger.Submit,
                                    mockContext.Object);

            // assert
            mockContext.VerifyAll();
        }
예제 #4
0
 public DocumentRepository(SiteDataContext dataContext, DocumentPersister documentPersister)
 {
     _dataContext       = dataContext;
     _documentPersister = documentPersister;
 }