From d340ac61fb63aadb976202cdf20d5fbe76c0df84 Mon Sep 17 00:00:00 2001 From: Joseph Woo Date: Fri, 10 Dec 2021 13:36:41 -0800 Subject: [PATCH 1/4] Updated Unit Test Error messages --- .../ADCIOSVisualizerTests.mm | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/source/ios/AdaptiveCards/ADCIOSVisualizer/ADCIOSVisualizerTests/ADCIOSVisualizerTests.mm b/source/ios/AdaptiveCards/ADCIOSVisualizer/ADCIOSVisualizerTests/ADCIOSVisualizerTests.mm index d9b152977f..0158b6bf80 100644 --- a/source/ios/AdaptiveCards/ADCIOSVisualizer/ADCIOSVisualizerTests/ADCIOSVisualizerTests.mm +++ b/source/ios/AdaptiveCards/ADCIOSVisualizer/ADCIOSVisualizerTests/ADCIOSVisualizerTests.mm @@ -200,35 +200,56 @@ - (void)parseAndRenderDFS:(NSString *)rootPath FileManager:(NSFileManager *)fMan if ([_setOfExpectedToFailFiles containsObject:fileName]) { XCTAssertFalse(cardParseResult.isValid); } else { - if (!cardParseResult.isValid) { - NSException *e = [NSException exceptionWithName:@"ParseFailed" reason:@"Parsing Failed" userInfo:nil]; - @throw e; - } - XCTAssertTrue(cardParseResult.isValid); + [self assertParsing:cardParseResult fileName:fileName]; ACRRenderResult *renderResult; @try { renderResult = [ACRRenderer render:cardParseResult.card config:nil widthConstraint:300 delegate:nil]; - XCTAssertTrue(renderResult.succeeded); + [self assertRendering:renderResult fileName:fileName]; } @catch (NSException *exception) { - NSString *exceptionMessage = [NSString stringWithFormat:@"%@", exception]; - printf("Render Failed while rendering %s\n%s", [fileName UTF8String], [exceptionMessage UTF8String]); - XCTAssertTrue(NO); + XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:@"Rendering Exception"]; + [self attachDataToIssueAndRecord:fileName issue:issue]; } } } @catch (NSException *exception) { - printf("Parsing Failed %s\n", [fileName UTF8String]); - for (NSError *parseError in cardParseResult.parseErrors) { - printf("%s\n", [parseError.userInfo[NSLocalizedDescriptionKey] UTF8String]); - } - XCTAssertTrue(NO); + [self assertParsing:cardParseResult fileName:fileName]; } } } + +- (void)attachDataToIssueAndRecord:(NSString *)fileName issue:(XCTMutableIssue *)issue +{ + NSData *data = [fileName dataUsingEncoding:NSUTF8StringEncoding]; + [issue addAttachment:[XCTAttachment attachmentWithData:data]]; + [self recordIssue:issue]; +} + +- (void)assertParsing:(ACOAdaptiveCardParseResult *)parseResult fileName:(NSString *)fileName +{ + if (!parseResult.isValid) { + XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:@"Object Model Parsing Failure"]; + + NSMutableArray *errorMsgs = [[NSMutableArray alloc] init]; + for (NSError *parseError in parseResult.parseErrors) { + [errorMsgs addObject:parseError.userInfo[NSLocalizedDescriptionKey]]; + } + + [self attachDataToIssueAndRecord:[NSString stringWithFormat:@" %@ in %@", [errorMsgs componentsJoinedByString:@", "], fileName] issue:issue]; + } +} + +- (void)assertRendering:(ACRRenderResult *)renderResult fileName:(NSString *)fileName +{ + if (!renderResult.succeeded) { + XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:@"Rendering Failure"]; + [self attachDataToIssueAndRecord:fileName issue:issue]; + } +} + - (void)testParsingAndRenderingAllCards { NSBundle *main = [NSBundle mainBundle]; From 4d7f19b5fa81cee57ab57008dfa07531445385d1 Mon Sep 17 00:00:00 2001 From: Joseph Woo Date: Fri, 10 Dec 2021 13:37:04 -0800 Subject: [PATCH 2/4] added test file -revert this commit in the future --- samples/v1.0/Elements/Input.Date.json | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/v1.0/Elements/Input.Date.json b/samples/v1.0/Elements/Input.Date.json index 86dd3ff4ba..31637c8f80 100644 --- a/samples/v1.0/Elements/Input.Date.json +++ b/samples/v1.0/Elements/Input.Date.json @@ -9,7 +9,6 @@ }, { "type": "Input.Date", - "id": "date", "placeholder": "Enter a date", "value": "2017-10-12" } From a1e86f6e77dd3199e701e7e2ce79bf1485d9b74f Mon Sep 17 00:00:00 2001 From: Joseph Woo Date: Fri, 10 Dec 2021 15:28:29 -0800 Subject: [PATCH 3/4] updated logging --- .../ADCIOSVisualizerTests.mm | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/source/ios/AdaptiveCards/ADCIOSVisualizer/ADCIOSVisualizerTests/ADCIOSVisualizerTests.mm b/source/ios/AdaptiveCards/ADCIOSVisualizer/ADCIOSVisualizerTests/ADCIOSVisualizerTests.mm index 0158b6bf80..71af9398aa 100644 --- a/source/ios/AdaptiveCards/ADCIOSVisualizer/ADCIOSVisualizerTests/ADCIOSVisualizerTests.mm +++ b/source/ios/AdaptiveCards/ADCIOSVisualizer/ADCIOSVisualizerTests/ADCIOSVisualizerTests.mm @@ -210,8 +210,8 @@ - (void)parseAndRenderDFS:(NSString *)rootPath FileManager:(NSFileManager *)fMan [self assertRendering:renderResult fileName:fileName]; } @catch (NSException *exception) { - XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:@"Rendering Exception"]; - [self attachDataToIssueAndRecord:fileName issue:issue]; + XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:[NSString stringWithFormat:@"Rendering Exception in %@", fileName]]; + [self recordIssue:issue]; } } } @@ -221,32 +221,23 @@ - (void)parseAndRenderDFS:(NSString *)rootPath FileManager:(NSFileManager *)fMan } } -- (void)attachDataToIssueAndRecord:(NSString *)fileName issue:(XCTMutableIssue *)issue -{ - NSData *data = [fileName dataUsingEncoding:NSUTF8StringEncoding]; - [issue addAttachment:[XCTAttachment attachmentWithData:data]]; - [self recordIssue:issue]; -} - - (void)assertParsing:(ACOAdaptiveCardParseResult *)parseResult fileName:(NSString *)fileName { if (!parseResult.isValid) { - XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:@"Object Model Parsing Failure"]; - NSMutableArray *errorMsgs = [[NSMutableArray alloc] init]; for (NSError *parseError in parseResult.parseErrors) { [errorMsgs addObject:parseError.userInfo[NSLocalizedDescriptionKey]]; } - - [self attachDataToIssueAndRecord:[NSString stringWithFormat:@" %@ in %@", [errorMsgs componentsJoinedByString:@", "], fileName] issue:issue]; + XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:[NSString stringWithFormat:@" %@ in %@", [errorMsgs componentsJoinedByString:@", "], fileName]]; + [self recordIssue:issue]; } } - (void)assertRendering:(ACRRenderResult *)renderResult fileName:(NSString *)fileName { if (!renderResult.succeeded) { - XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:@"Rendering Failure"]; - [self attachDataToIssueAndRecord:fileName issue:issue]; + XCTMutableIssue *issue = [[XCTMutableIssue alloc] initWithType:XCTIssueTypeAssertionFailure compactDescription:[NSString stringWithFormat:@"Rendering Failure in %@", fileName]]; + [self recordIssue:issue]; } } From 506aeb196f16e08f9cd51aa47c7cbae9b03518ca Mon Sep 17 00:00:00 2001 From: Joseph Woo Date: Fri, 10 Dec 2021 15:43:17 -0800 Subject: [PATCH 4/4] Revert "added test file -revert this commit in the future" This reverts commit 4d7f19b5fa81cee57ab57008dfa07531445385d1. --- samples/v1.0/Elements/Input.Date.json | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/v1.0/Elements/Input.Date.json b/samples/v1.0/Elements/Input.Date.json index 31637c8f80..86dd3ff4ba 100644 --- a/samples/v1.0/Elements/Input.Date.json +++ b/samples/v1.0/Elements/Input.Date.json @@ -9,6 +9,7 @@ }, { "type": "Input.Date", + "id": "date", "placeholder": "Enter a date", "value": "2017-10-12" }