Explorar el Código

Updated tests in GIDEMMSupportTest

Akshat Gandhi hace 5 meses
padre
commit
910896402b
Se han modificado 1 ficheros con 42 adiciones y 16 borrados
  1. 42 16
      GoogleSignIn/Tests/Unit/GIDEMMSupportTest.m

+ 42 - 16
GoogleSignIn/Tests/Unit/GIDEMMSupportTest.m

@@ -283,9 +283,15 @@ static NSString *const kEMMPasscodeInfoKey = @"emm_passcode_info";
                                                                      emmSupport:@"1"
                                                          isPasscodeInfoRequired:NO];
 
-  [self assertAllKeysAndValuesAreStringsInDictionary:stringifiedParameters];
   XCTAssertEqualObjects(stringifiedParameters[@"number_key"], @"12345",
                         @"The NSNumber should be converted to a string.");
+  [stringifiedParameters enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
+    XCTAssertTrue([key isKindOfClass:[NSString class]],
+                  @"All keys must be NSStrings. Found a key of type '%@'.", [key class]);
+    XCTAssertTrue([obj isKindOfClass:[NSString class]],
+                  @"All values must be NSStrings. Found a value of type '%@' for key '%@'.",
+                  [obj class], key);
+  }];
 }
 
 - (void)testParametersWithParameters_withNumberOne_isConvertedToString {
@@ -295,9 +301,15 @@ static NSString *const kEMMPasscodeInfoKey = @"emm_passcode_info";
                                                                      emmSupport:@"1"
                                                          isPasscodeInfoRequired:NO];
 
-  [self assertAllKeysAndValuesAreStringsInDictionary:stringifiedParameters];
   XCTAssertEqualObjects(stringifiedParameters[@"number_key"], @"1",
                         @"The NSNumber should be converted to a string.");
+  [stringifiedParameters enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
+    XCTAssertTrue([key isKindOfClass:[NSString class]],
+                  @"All keys must be NSStrings. Found a key of type '%@'.", [key class]);
+    XCTAssertTrue([obj isKindOfClass:[NSString class]],
+                  @"All values must be NSStrings. Found a value of type '%@' for key '%@'.",
+                  [obj class], key);
+  }];
 }
 
 - (void)testParametersWithParameters_withNumberZero_isConvertedToString {
@@ -307,9 +319,15 @@ static NSString *const kEMMPasscodeInfoKey = @"emm_passcode_info";
                                                                      emmSupport:@"1"
                                                          isPasscodeInfoRequired:NO];
 
-  [self assertAllKeysAndValuesAreStringsInDictionary:stringifiedParameters];
   XCTAssertEqualObjects(stringifiedParameters[@"number_key"], @"0",
                         @"The NSNumber should be converted to a string.");
+  [stringifiedParameters enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
+    XCTAssertTrue([key isKindOfClass:[NSString class]],
+                  @"All keys must be NSStrings. Found a key of type '%@'.", [key class]);
+    XCTAssertTrue([obj isKindOfClass:[NSString class]],
+                  @"All values must be NSStrings. Found a value of type '%@' for key '%@'.",
+                  [obj class], key);
+  }];
 }
 
 - (void)testParametersWithParameters_withBooleanYes_isConvertedToTrueString {
@@ -319,9 +337,15 @@ static NSString *const kEMMPasscodeInfoKey = @"emm_passcode_info";
                                                                      emmSupport:@"1"
                                                          isPasscodeInfoRequired:NO];
 
-  [self assertAllKeysAndValuesAreStringsInDictionary:stringifiedParameters];
   XCTAssertEqualObjects(stringifiedParameters[@"bool_key"], @"true",
                         @"The boolean YES should be converted to the string 'true'.");
+  [stringifiedParameters enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
+    XCTAssertTrue([key isKindOfClass:[NSString class]],
+                  @"All keys must be NSStrings. Found a key of type '%@'.", [key class]);
+    XCTAssertTrue([obj isKindOfClass:[NSString class]],
+                  @"All values must be NSStrings. Found a value of type '%@' for key '%@'.",
+                  [obj class], key);
+  }];
 }
 
 - (void)testParametersWithParameters_withBooleanNo_isConvertedToFalseString {
@@ -331,9 +355,15 @@ static NSString *const kEMMPasscodeInfoKey = @"emm_passcode_info";
                                                                      emmSupport:@"1"
                                                          isPasscodeInfoRequired:NO];
 
-  [self assertAllKeysAndValuesAreStringsInDictionary:stringifiedParameters];
   XCTAssertEqualObjects(stringifiedParameters[@"bool_key"], @"false",
                         @"The boolean NO should be converted to the string 'false'.");
+  [stringifiedParameters enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
+    XCTAssertTrue([key isKindOfClass:[NSString class]],
+                  @"All keys must be NSStrings. Found a key of type '%@'.", [key class]);
+    XCTAssertTrue([obj isKindOfClass:[NSString class]],
+                  @"All values must be NSStrings. Found a value of type '%@' for key '%@'.",
+                  [obj class], key);
+  }];
 }
 
 - (void)testParametersWithParameters_withString_remainsUnchanged {
@@ -343,9 +373,15 @@ static NSString *const kEMMPasscodeInfoKey = @"emm_passcode_info";
                                                                      emmSupport:@"1"
                                                          isPasscodeInfoRequired:NO];
 
-  [self assertAllKeysAndValuesAreStringsInDictionary:stringifiedParameters];
   XCTAssertEqualObjects(stringifiedParameters[@"string_key"], @"hello",
                         @"The original string value should be preserved.");
+  [stringifiedParameters enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
+    XCTAssertTrue([key isKindOfClass:[NSString class]],
+                  @"All keys must be NSStrings. Found a key of type '%@'.", [key class]);
+    XCTAssertTrue([obj isKindOfClass:[NSString class]],
+                  @"All values must be NSStrings. Found a value of type '%@' for key '%@'.",
+                  [obj class], key);
+  }];
 }
 
 # pragma mark - Helpers
@@ -376,16 +412,6 @@ static NSString *const kEMMPasscodeInfoKey = @"emm_passcode_info";
   self.presentedViewController = nil;
 }
 
-- (void)assertAllKeysAndValuesAreStringsInDictionary:(NSDictionary *)dictionary {
-  [dictionary enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
-    XCTAssertTrue([key isKindOfClass:[NSString class]],
-                  @"All keys must be NSStrings. Found a key of type '%@'.", [key class]);
-    XCTAssertTrue([obj isKindOfClass:[NSString class]],
-                  @"All values must be NSStrings. Found a value of type '%@' for key '%@'.",
-                  [obj class], key);
-  }];
-}
-
 @end
 
 NS_ASSUME_NONNULL_END