@@ -33,6 +33,7 @@ public class LanguageTranslatorV3IntegrationTests
3333 private string versionDate = "2019-02-13" ;
3434 private string forcedGlossaryFilepath ;
3535 private string translateDocumentPath ;
36+ private string documentId ;
3637 private string englishText = "Where is the library?" ;
3738 private string spanishText = "¿Dónde está la biblioteca?" ;
3839 private string englishToSpanishModel = "en-es" ;
@@ -266,14 +267,15 @@ public IEnumerator TestTranslateDocument()
266267 service . TranslateDocument (
267268 callback : ( DetailedResponse < DocumentStatus > response , IBMError error ) =>
268269 {
269- Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Translate result: {0}" , response . Response ) ;
270+ Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Translate Document result: {0}" , response . Response ) ;
270271 documentStatus = response . Result ;
271272 Assert . IsNotNull ( documentStatus ) ;
272273 Assert . IsNotNull ( documentStatus . DocumentId ) ;
274+ documentId = documentStatus . DocumentId ;
273275 Assert . IsNull ( error ) ;
274276 } ,
275277 file : ms ,
276- filename : "trabslate -document.txt" ,
278+ filename : "translate -document.txt" ,
277279 modelId : "en-fr"
278280 ) ;
279281
@@ -285,32 +287,71 @@ public IEnumerator TestTranslateDocument()
285287 #endregion
286288
287289 #region List Documents
288- [ UnityTest , Order ( 99 ) ]
290+ [ UnityTest , Order ( 9 ) ]
289291 public IEnumerator TestListDocuments ( )
290292 {
291- Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Attempting to Translate ..." ) ;
293+ Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Getting the document list ..." ) ;
292294 DocumentList documents = null ;
293295
294- using ( FileStream fs = File . OpenRead ( translateDocumentPath ) )
295- {
296- using ( MemoryStream ms = new MemoryStream ( ) )
296+ service . ListDocuments (
297+ callback : ( DetailedResponse < DocumentList > response , IBMError error ) =>
297298 {
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 ;
299+ Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "List Documents result: {0}" , response . Response ) ;
300+ documents = response . Result ;
301+ Assert . IsNotNull ( documents ) ;
302+ Assert . IsNull ( error ) ;
311303 }
312- }
304+ ) ;
305+
306+ while ( documents == null )
307+ yield return null ;
313308 }
314309 #endregion
310+
311+ #region Get Document Status
312+ [ UnityTest , Order ( 10 ) ]
313+ public IEnumerator TestGetDocumentStatus ( )
314+ {
315+ Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Getting document status..." ) ;
316+ DocumentStatus documentStatus = null ;
317+
318+ service . GetDocumentStatus (
319+ callback : ( DetailedResponse < DocumentStatus > response , IBMError error ) =>
320+ {
321+ Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Get Document Status: {0}" , response . Response ) ;
322+ documentStatus = response . Result ;
323+ Assert . IsNotNull ( documentStatus ) ;
324+ Assert . IsNull ( error ) ;
325+ } ,
326+ documentId : documentId
327+ ) ;
328+
329+ while ( documentStatus == null )
330+ yield return null ;
315331 }
316- }
332+ #endregion
333+
334+ #region Delete Document
335+ [ UnityTest , Order ( 99 ) ]
336+ public IEnumerator TestDeletetDocument ( )
337+ {
338+ Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Deleteing the Document..." ) ;
339+ object deleteResponse = null ;
340+
341+ service . DeleteDocument (
342+ callback : ( DetailedResponse < object > response , IBMError error ) =>
343+ {
344+ Log . Debug ( "LanguageTranslatorServiceV3IntegrationTests" , "Delete Document result: {0}" , response . Response ) ;
345+ deleteResponse = response . Result ;
346+ Assert . IsTrue ( response . StatusCode == 204 ) ;
347+ Assert . IsNull ( error ) ;
348+ } ,
349+ documentId : documentId
350+ ) ;
351+
352+ while ( deleteResponse == null )
353+ yield return null ;
354+ }
355+ #endregion
356+ }
357+ }
0 commit comments