@@ -32,6 +32,7 @@ public class LanguageTranslatorV3IntegrationTests
3232 private LanguageTranslatorService service ;
3333 private string versionDate = "2019-02-13" ;
3434 private string forcedGlossaryFilepath ;
35+ private string translateDocumentPath ;
3536 private string englishText = "Where is the library?" ;
3637 private string spanishText = "¿Dónde está la biblioteca?" ;
3738 private string englishToSpanishModel = "en-es" ;
@@ -44,6 +45,7 @@ public void OneTimeSetup()
4445 {
4546 LogSystem . InstallDefaultReactors ( ) ;
4647 forcedGlossaryFilepath = Application . dataPath + "/Watson/Tests/TestData/LanguageTranslatorV3/glossary.tmx" ;
48+ translateDocumentPath = Application . dataPath + "/Watson/Tests/TestData/LanguageTranslatorV3/translate-document.txt" ;
4749 }
4850
4951 [ UnitySetUp ]
@@ -226,7 +228,7 @@ public IEnumerator TestListModels()
226228 #endregion
227229
228230 #region DeleteModel
229- [ UnityTest , Order ( 99 ) ]
231+ [ UnityTest , Order ( 7 ) ]
230232 public IEnumerator TestDeleteModel ( )
231233 {
232234 Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Attempting to DeleteModel..." ) ;
@@ -248,5 +250,67 @@ public IEnumerator TestDeleteModel()
248250 yield return null ;
249251 }
250252 #endregion
251- }
252- }
253+
254+ #region Translate Document
255+ [ UnityTest , Order ( 8 ) ]
256+ public IEnumerator TestTranslateDocument ( )
257+ {
258+ Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Attempting to Translate..." ) ;
259+ DocumentStatus documentStatus = null ;
260+
261+ using ( FileStream fs = File . OpenRead ( translateDocumentPath ) )
262+ {
263+ using ( MemoryStream ms = new MemoryStream ( ) )
264+ {
265+ fs . CopyTo ( ms ) ;
266+ service . TranslateDocument (
267+ callback : ( DetailedResponse < DocumentStatus > response , IBMError error ) =>
268+ {
269+ Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Translate result: {0}" , response . Response ) ;
270+ documentStatus = response . Result ;
271+ Assert . IsNotNull ( documentStatus ) ;
272+ Assert . IsNotNull ( documentStatus . DocumentId ) ;
273+ Assert . IsNull ( error ) ;
274+ } ,
275+ file : ms ,
276+ filename : "trabslate-document.txt" ,
277+ modelId : "en-fr"
278+ ) ;
279+
280+ while ( documentStatus == null )
281+ yield return null ;
282+ }
283+ }
284+ }
285+ #endregion
286+
287+ #region List Documents
288+ [ UnityTest , Order ( 99 ) ]
289+ public IEnumerator TestListDocuments ( )
290+ {
291+ Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Attempting to Translate..." ) ;
292+ DocumentList documents = null ;
293+
294+ using ( FileStream fs = File . OpenRead ( translateDocumentPath ) )
295+ {
296+ using ( MemoryStream ms = new MemoryStream ( ) )
297+ {
298+ fs . CopyTo ( ms ) ;
299+ service . ListDocuments (
300+ callback : ( DetailedResponse < DocumentList > response , IBMError error ) =>
301+ {
302+ Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Translate result: {0}" , response . Response ) ;
303+ documents = response . Result ;
304+ Assert . IsNotNull ( documents ) ;
305+ Assert . IsNull ( error ) ;
306+ }
307+ ) ;
308+
309+ while ( documents == null )
310+ yield return null ;
311+ }
312+ }
313+ }
314+ #endregion
315+ }
316+ }
0 commit comments