@@ -81,8 +81,8 @@ public async Task SyncTest()
8181 public async Task HierarchicalTest ( )
8282 {
8383 var calendarFile = await CreateCalendar ( ) ;
84- var request = new GetCalendarRequest ( calendarFile , folder , StorageName ) ;
85- var calendar = await emailApi . GetCalendarAsync ( request ) ;
84+ var calendar = await emailApi . GetCalendarAsync (
85+ new GetCalendarRequest ( calendarFile , folder , StorageName ) ) ;
8686 Assert . AreEqual ( "CALENDAR" , calendar . Name ) ;
8787 Assert . GreaterOrEqual (
8888 calendar . InternalProperties
@@ -104,15 +104,15 @@ public async Task StreamTest()
104104 var calendarFile = await CreateCalendar ( ) ;
105105 var newFileName = $ "{ Guid . NewGuid ( ) . ToString ( ) } .ics";
106106 var newPath = $ "{ folder } /{ newFileName } ";
107- var request = new DownloadFileRequest ( $ " { folder } / { calendarFile } " , StorageName ) ;
108- using ( var stream = await emailApi . DownloadFileAsync ( request ) )
107+ using ( var stream = await emailApi . DownloadFileAsync (
108+ new DownloadFileRequest ( $ " { folder } / { calendarFile } " , StorageName ) ) )
109109 {
110110 var uploadRequest = new UploadFileRequest ( newPath , stream , StorageName ) ;
111111 await emailApi . UploadFileAsync ( uploadRequest ) ;
112112 }
113113
114- var existRequest = new ObjectExistsRequest ( newPath , StorageName ) ;
115- var newFileExist = await emailApi . ObjectExistsAsync ( existRequest ) ;
114+ var newFileExist = await emailApi . ObjectExistsAsync (
115+ new ObjectExistsRequest ( newPath , StorageName ) ) ;
116116 Assert . IsTrue ( newFileExist . Exists ) ;
117117 Assert . IsFalse ( newFileExist . IsFolder ) ;
118118 }
@@ -128,19 +128,11 @@ public async Task ContactFormatTest()
128128 foreach ( var format in new [ ] { "vcard" , "msg" } )
129129 {
130130 var extension = format == "vcard" ? ".vcf" : ".msg" ;
131- var request = new CreateContactRequest
132- {
133- format = format ,
134- name = $ "{ Guid . NewGuid ( ) . ToString ( ) } { extension } ",
135- request = new HierarchicalObjectRequest
136- {
137- StorageFolder = new StorageFolderLocation { Storage = StorageName , FolderPath = folder } ,
138- HierarchicalObject = new HierarchicalObject
139- { Name = "CONTACT" , InternalProperties = new List < BaseObject > ( ) }
140- }
141- } ;
142- await emailApi . CreateContactAsync ( request ) ;
143- var contactExist = await IsFileExist ( request . name ) ;
131+ var name = $ "{ Guid . NewGuid ( ) . ToString ( ) } { extension } ";
132+ await emailApi . CreateContactAsync ( new CreateContactRequest ( format , name ,
133+ new HierarchicalObjectRequest ( new HierarchicalObject ( "CONTACT" , null , new List < BaseObject > ( ) ) ,
134+ new StorageFolderLocation ( StorageName , folder ) ) ) ) ;
135+ var contactExist = await IsFileExist ( name ) ;
144136 Assert . IsTrue ( contactExist ) ;
145137 }
146138 }
@@ -156,8 +148,7 @@ public async Task DateTimeTest()
156148 {
157149 var startDate = DateTime . UtcNow . Date . AddDays ( 1 ) . AddHours ( 12 ) ;
158150 var calendarFile = await CreateCalendar ( startDate ) ;
159- var request = new GetCalendarRequest ( calendarFile , folder , StorageName ) ;
160- var calendar = await emailApi . GetCalendarAsync ( request ) ;
151+ var calendar = await emailApi . GetCalendarAsync ( new GetCalendarRequest ( calendarFile , folder , StorageName ) ) ;
161152 var startDateProperty = calendar . InternalProperties
162153 . First ( property => property . Name == "STARTDATE" ) ;
163154 var factStartDate = DateTime
@@ -184,9 +175,7 @@ public async Task AiNameGenderizeTest()
184175 public async Task AiNameFormatTest ( )
185176 {
186177 var result = await emailApi . AiNameFormatAsync (
187- new AiNameFormatRequest (
188- "Mr. John Michael Cane" ,
189- format : "%t%L%f%m" ) ) ;
178+ new AiNameFormatRequest ( "Mr. John Michael Cane" , format : "%t%L%f%m" ) ) ;
190179 Assert . AreEqual ( "Mr. Cane J. M." , result . Name ) ;
191180 }
192181
@@ -209,8 +198,7 @@ public async Task AiNameExpandTest()
209198 const string name = "Smith Bobby" ;
210199 var result = await emailApi . AiNameExpandAsync (
211200 new AiNameExpandRequest ( name ) ) ;
212- var expandedNames = result
213- . Names
201+ var expandedNames = result . Names
214202 . Select ( weightedName => weightedName . Name )
215203 . ToList ( ) ;
216204 Assert . Contains ( "Mr. Smith" , expandedNames ) ;
@@ -267,27 +255,10 @@ public async Task AiBcrParseStorageTest()
267255 await emailApi . CreateFolderAsync ( new CreateFolderRequest ( outFolderPath , StorageName ) ) ;
268256 // 2) Call business card recognition action
269257 var result = await emailApi . AiBcrParseStorageAsync ( new AiBcrParseStorageRequest (
270- new AiBcrParseStorageRq
271- {
272- Images = new List < AiBcrImageStorageFile >
273- {
274- new AiBcrImageStorageFile
275- {
276- File = new StorageFileLocation
277- {
278- Storage = StorageName ,
279- FileName = fileName ,
280- FolderPath = folder
281- } ,
282- IsSingle = true
283- }
284- } ,
285- OutFolder = new StorageFolderLocation
286- {
287- Storage = StorageName ,
288- FolderPath = outFolderPath
289- }
290- } ) ) ;
258+ new AiBcrParseStorageRq ( null ,
259+ new List < AiBcrImageStorageFile >
260+ { new AiBcrImageStorageFile ( true , new StorageFileLocation ( StorageName , folder , fileName ) ) } ,
261+ new StorageFolderLocation ( StorageName , outFolderPath ) ) ) ) ;
291262 //Check that only one file produced
292263 Assert . True ( result . Value . Count == 1 ) ;
293264 // 3) Get file name from recognition result
@@ -296,13 +267,13 @@ public async Task AiBcrParseStorageTest()
296267 // 4) Download VCard file, produced by recognition method, check it contains text "Thomas"
297268 using ( var contactFileStream = await emailApi . DownloadFileAsync ( new DownloadFileRequest (
298269 $ "{ contactFile . FolderPath } /{ contactFile . FileName } ", contactFile . Storage ) ) )
299- using ( var memoryStream = new MemoryStream ( ) )
270+ using ( var memoryStream = new MemoryStream ( ) )
300271 {
301272 contactFileStream . CopyTo ( memoryStream ) ;
302273 var contactFileContent = Encoding . UTF8 . GetString ( memoryStream . ToArray ( ) ) ;
303274 Assert . True ( contactFileContent . Contains ( "Thomas" ) ) ;
304275 }
305-
276+
306277 // 5) Get VCard object properties list, check that there are 3 properties or more
307278 var contactProperties = await emailApi . GetContactPropertiesAsync ( new GetContactPropertiesRequest (
308279 "vcard" , contactFile . FileName , contactFile . FolderPath , contactFile . Storage ) ) ;
@@ -316,25 +287,14 @@ public async Task AiBcrParseStorageTest()
316287 [ Test ]
317288 public async Task AiBcrParseTest ( )
318289 {
319- var result = await emailApi . AiBcrParseAsync (
320- new AiBcrParseRequest (
321- new AiBcrBase64Rq
322- {
323- Images = new List < AiBcrBase64Image >
324- {
325- new AiBcrBase64Image
326- {
327- Base64Data = FileToBase64 ( BcrAiTestFilePath ) ,
328- IsSingle = true
329- }
330- }
331- } ) ) ;
290+ var result = await emailApi . AiBcrParseAsync ( new AiBcrParseRequest ( new AiBcrBase64Rq ( null ,
291+ new List < AiBcrBase64Image > { new AiBcrBase64Image ( true , FileToBase64 ( BcrAiTestFilePath ) ) } ) ) ) ;
332292 Assert . AreEqual ( 1 , result . Value . Count ) ;
333293 Assert . True ( result . Value
334294 . First ( )
335295 . InternalProperties
336296 . Where ( property => property . Type == nameof ( PrimitiveObject ) )
337- . Select ( property => ( PrimitiveObject ) property )
297+ . Select ( property => ( PrimitiveObject ) property )
338298 . Any ( property => property . Value ? . Contains ( "Thomas" ) ?? false ) ) ;
339299 }
340300
@@ -357,49 +317,31 @@ private async Task<string> CreateCalendar(DateTime? startDate = null)
357317 var fileName = $ "{ Guid . NewGuid ( ) . ToString ( ) } .ics";
358318 startDate = startDate ?? DateTime . UtcNow . Date . AddDays ( 1 ) . AddHours ( 12 ) ;
359319 var endDate = startDate . Value . AddHours ( 1 ) ;
360- var request = new CreateCalendarRequest
361- {
362- name = fileName ,
363- request = new HierarchicalObjectRequest
364- {
365- HierarchicalObject = new HierarchicalObject
366- {
367- Name = "CALENDAR" , InternalProperties = new List < BaseObject >
320+ var request = new CreateCalendarRequest ( fileName ,
321+ new HierarchicalObjectRequest (
322+ new HierarchicalObject ( "CALENDAR" , null ,
323+ new List < BaseObject >
368324 {
369- new PrimitiveObject { Name = "LOCATION" , Value = "location" } ,
370- new PrimitiveObject { Name = "STARTDATE" , Value = startDate . Value . ToString ( "u" ) } ,
371- new PrimitiveObject { Name = "ENDDATE" , Value = endDate . ToString ( "u" ) } ,
372- new HierarchicalObject
373- {
374- Name = "ORGANIZER" , InternalProperties = new List < BaseObject >
325+ new PrimitiveObject ( "LOCATION" , null , "location" ) ,
326+ new PrimitiveObject ( "STARTDATE" , null , startDate . Value . ToString ( "u" ) ) ,
327+ new PrimitiveObject ( "ENDDATE" , null , endDate . ToString ( "u" ) ) ,
328+ new HierarchicalObject ( "ORGANIZER" , null ,
329+ new List < BaseObject >
375330 {
376- new PrimitiveObject { Name = "ADDRESS" , Value = "organizer@am.ru" } ,
377- new PrimitiveObject { Name = "DISPLAYNAME" , Value = "Piu Man" }
378- }
379- } ,
380- new HierarchicalObject
381- {
382- Name = "ATTENDEES" , InternalProperties = new List < BaseObject >
331+ new PrimitiveObject ( "ADDRESS" , null , "organizer@am.ru" ) ,
332+ new PrimitiveObject ( "DISPLAYNAME" , null , "Piu Man" )
333+ } ) ,
334+ new HierarchicalObject ( "ATTENDEES" , null ,
335+ new List < BaseObject >
383336 {
384- new IndexedHierarchicalObject
385- {
386- Index = 0 , Name = "ATTENDEE" , InternalProperties = new List < BaseObject >
337+ new IndexedHierarchicalObject ( "ATTENDEE" , null , 0 ,
338+ new List < BaseObject >
387339 {
388- new PrimitiveObject { Name = "ADDRESS" , Value = "attendee@am.ru" } ,
389- new PrimitiveObject { Name = "DISPLAYNAME" , Value = "Attendee Name" }
390- }
391- }
392- }
393- }
394- }
395- } ,
396- StorageFolder = new StorageFolderLocation
397- {
398- Storage = "First Storage" ,
399- FolderPath = folder
400- }
401- }
402- } ;
340+ new PrimitiveObject ( "ADDRESS" , null , "attendee@am.ru" ) ,
341+ new PrimitiveObject ( "DISPLAYNAME" , null , "Attendee Name" )
342+ } )
343+ } )
344+ } ) , new StorageFolderLocation ( StorageName , folder ) ) ) ;
403345 await emailApi . CreateCalendarAsync ( request ) ;
404346 return fileName ;
405347 }
0 commit comments