Ejemplo n.º 1
0
        /// <summary>
        /// Opens translation data from word document.
        /// </summary>
        /// <param name="path">Path of the file.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <returns>Object that implements Translation Data Interface.</returns>
        public ITranslationData OpenDocFile(string path, string fileName)
        {
            Application application = new Application();
            Document    document    = new Document();

            document = application.Documents.Open(path);

            var data = _translationDataFactory.CreateTranslationDataFromDocument(fileName, document);

            document.Close();
            application.Quit();

            return(data);
        }
            public void TranslationDataFactory_CreateTranslationDataFromDocument_Test()
            {
                // Arrange
                var expected = new TranslationData(mockProjectData.Object, mockSubTranslationDataFactory.Object)
                {
                    DataChanged = false
                };

                var expectedDataChanged = expected.DataChanged;

                // Act
                var actual            = translationDataFactory.CreateTranslationDataFromDocument("", new Document());
                var actualDataChanged = actual.DataChanged;

                // Assert
                mockProjectDataFactory.Verify(x => x.CreateProjectDataFromDocument(It.IsAny <string>(), It.IsAny <Document>()), Times.Once);

                Assert.IsType <TranslationData>(actual);
                Assert.IsAssignableFrom <ITranslationData>(actual);
                Assert.NotStrictEqual(expected, actual);
                Assert.Equal(expectedDataChanged, actualDataChanged);
            }