regulaforensics / DocumentReader-iOS

iOS Framework for reading and validation of identification documents
56 stars 15 forks source link

How can I create an Instance of RGLDocumentReaderResults with dictionary. #24

Closed kamarshad closed 4 years ago

kamarshad commented 4 years ago

Hi @syakimchik @DmitrySmolyakov @ikliashchou I am using this wonderful library for document scanning purpose. I am stuck at a place actually I want to stub the RGLDocumentReaderResults class with a predefined set of hard code information. This all I want to do is to write the Unit Test cases :)

I tried to explore that class and found two methods (instance and class) which accept a dictionary. But I am not sure how to build that dictionary so that I could stub it.

Can you please guide me in creating the stub?

Thanks

DzmitrySmaliakou commented 4 years ago

Hello @kamarshad,

You can use RGLDocumentReaderResults initializer, I mean initWith RGLDocumentReaderTextResult, RGLDocumentReaderGraphicResult, and other results classes, but I think it's not a good idea. Our RGLDocumentReaderResults contains a big amount of different information, which may remain unused.

I think the better way to create your own results class, which will contain the necessary for you results.

kamarshad commented 4 years ago

Thank you for your reply. Yes, you are right using the initializer is not a good idea. I guess passing dictionary can be a good option. I just want to prepare different variations of RGLDocumentReaderResults class surround to RGLCheckResult enum. But I am not able to understand how to wrap up the RGLCheckResult in the dictionary.

Please advice.

DzmitrySmaliakou commented 4 years ago

RGLCheckResult is NSInteger, so if you use Swift just get .rawValue, if Objective C use NSNumber to wrap it and put to NSDictionary

kamarshad commented 4 years ago

Sorry I did not explain it properly. My question was what key should be used when I put in dictionary. So when I access the RGLCheckResult/CheckResult) without any issue.

DzmitrySmaliakou commented 4 years ago

You are talking about initWithJSON function? If yes, we don't use it in our implementation now, so I can't say that it will work properly. Meanwhile, we use "overallResult" key in initWithJSON initializer to set RGLCheckResult variable

kamarshad commented 4 years ago

Yes, I was talking about initWithJSON function. Thank you