From 263a2dd3eb95aba18758c40c609ab46523070d24 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Sun, 29 Sep 2024 17:16:50 -0700 Subject: [PATCH] . d Fix ObjC presented/dismissed vc examples to use XCTAssertIdentical --- .../xcode/package.xcworkspace/contents.xcworkspacedata | 7 +++++++ ObjCSample/Tests/ViewControllerAlertTests.m | 4 ++-- ObjCSample/Tests/ViewControllerPresentationTests.m | 6 +++--- README.md | 6 +++--- 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ObjCSample/Tests/ViewControllerAlertTests.m b/ObjCSample/Tests/ViewControllerAlertTests.m index 9024d80..d62f166 100644 --- a/ObjCSample/Tests/ViewControllerAlertTests.m +++ b/ObjCSample/Tests/ViewControllerAlertTests.m @@ -44,7 +44,7 @@ - (void)test_tappingShowAlertButton_shouldPresentAlert XCTAssertEqual(alertVerifier.presentedCount, 1, @"presented count"); XCTAssertEqual(alertVerifier.preferredStyle, UIAlertControllerStyleAlert, @"preferred style"); - XCTAssertEqual(alertVerifier.presentingViewController, sut, @"presenting view controller"); + XCTAssertIdentical(alertVerifier.presentingViewController, sut, @"presenting view controller"); XCTAssertTrue(alertVerifier.animated, @"animated"); XCTAssertEqualObjects(alertVerifier.title, @"Title", @"title"); XCTAssertEqualObjects(alertVerifier.message, @"Message", @"message"); @@ -56,7 +56,7 @@ - (void)test_tappingShowActionSheetButton_shouldPresentActionSheet XCTAssertEqual(alertVerifier.presentedCount, 1, @"presented count"); XCTAssertEqual(alertVerifier.preferredStyle, UIAlertControllerStyleActionSheet, @"preferred style"); - XCTAssertEqual(alertVerifier.presentingViewController, sut, @"presenting view controller"); + XCTAssertIdentical(alertVerifier.presentingViewController, sut, @"presenting view controller"); XCTAssertTrue(alertVerifier.animated, @"animated"); XCTAssertEqualObjects(alertVerifier.title, @"Title", @"title"); XCTAssertEqualObjects(alertVerifier.message, @"Message", @"message"); diff --git a/ObjCSample/Tests/ViewControllerPresentationTests.m b/ObjCSample/Tests/ViewControllerPresentationTests.m index c7bbd02..c2befa6 100644 --- a/ObjCSample/Tests/ViewControllerPresentationTests.m +++ b/ObjCSample/Tests/ViewControllerPresentationTests.m @@ -49,7 +49,7 @@ - (void)test_tappingSeguePresentModalButton_shouldPresentNextViewControllerWithG [sut.seguePresentModalButton sendActionsForControlEvents:UIControlEventTouchUpInside]; XCTAssertEqual(presentationVerifier.presentedCount, 1, @"presented count"); - XCTAssertEqual(presentationVerifier.presentingViewController, sut, @"presenting view controller"); + XCTAssertIdentical(presentationVerifier.presentingViewController, sut, @"presenting view controller"); XCTAssertTrue(presentationVerifier.animated, @"animated"); if (![presentationVerifier.presentedViewController isKindOfClass:[StoryboardNextViewController class]]) { @@ -70,7 +70,7 @@ - (void)test_tappingSegueShowButton_shouldShowNextViewControllerWithRedBackgroun [sut.segueShowButton sendActionsForControlEvents:UIControlEventTouchUpInside]; XCTAssertEqual(presentationVerifier.presentedCount, 1, @"presented count"); - XCTAssertEqual(presentationVerifier.presentingViewController, sut, @"presenting view controller"); + XCTAssertIdentical(presentationVerifier.presentingViewController, sut, @"presenting view controller"); XCTAssertTrue(presentationVerifier.animated, @"animated"); if (![presentationVerifier.presentedViewController isKindOfClass:[StoryboardNextViewController class]]) { @@ -87,7 +87,7 @@ - (void)test_tappingCodeModalButton_shouldPresentNextViewControllerWithPurpleBac [sut.codePresentModalButton sendActionsForControlEvents:UIControlEventTouchUpInside]; XCTAssertEqual(presentationVerifier.presentedCount, 1, @"presented count"); - XCTAssertEqual(presentationVerifier.presentingViewController, sut, @"presenting view controller"); + XCTAssertIdentical(presentationVerifier.presentingViewController, sut, @"presenting view controller"); XCTAssertTrue(presentationVerifier.animated, @"animated"); if (![presentationVerifier.presentedViewController isKindOfClass:[CodeNextViewController class]]) { diff --git a/README.md b/README.md index d3c2049..1805f96 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ func test_showAlert_alertShouldHaveTitle() { XCTAssertEqualObjects(alertVerifier.message, @"How are you?", @"message"); XCTAssertEqual(alertVerifier.animated, YES, @"animated"); XCTAssertEqual(alertVerifier.preferredStyle, UIAlertController.Style.alert, @"preferred style"); - XCTAssertEqual(alertVerifier.presentingViewController, sut, @"presenting view controller"); + XCTAssertIdentical(alertVerifier.presentingViewController, sut, @"presenting view controller"); XCTAssertEqual(alertVerifier.actions.count, 2, @"actions count); XCTAssertEqualObjects(alertVerifier.actions[0].title, @"OK", @"first action"); XCTAssertEqual(alertVerifier.actions[0].style, UIAlertActionStyleDefault, @"first action"); @@ -180,7 +180,7 @@ func test_presentedVC_shouldHaveSpecialSettingHello() { XCTAssertEqual(presentationVerifier.presentedCount, 1, @"presented count"); XCTAssertTrue(presentationVerifier.animated, @"animated"); - XCTAssertEqual(presentationVerifier.presentingViewController, sut, @"presenting view controller"); + XCTAssertIdentical(presentationVerifier.presentingViewController, sut, @"presenting view controller"); if (![presentationVerifier.presentedViewController isKindOfClass:[MyViewController class]]) { XCTFail(@"Expected MyViewController, but was %@", presentationVerifier.presentedViewController); @@ -261,7 +261,7 @@ func test_dismissingVC() { XCTAssertEqual(dismissalVerifier.dismissedCount, 1, @"dismissed count"); XCTAssertTrue(dismissalVerifier.animated, @"animated"); - XCTAssertEqual(dismissalVerifier.presentingViewController, sut, @"dismissed view controller"); + XCTAssertIdentical(dismissalVerifier.dismissedViewController, sut, @"dismissed view controller"); } ```