Skip to content

Commit

Permalink
. d Fix ObjC presented/dismissed vc examples to use XCTAssertIdentical
Browse files Browse the repository at this point in the history
  • Loading branch information
jonreid committed Sep 30, 2024
1 parent e58d38a commit 263a2dd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ObjCSample/Tests/ViewControllerAlertTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
6 changes: 3 additions & 3 deletions ObjCSample/Tests/ViewControllerPresentationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]])
{
Expand All @@ -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]])
{
Expand All @@ -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]])
{
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
```

Expand Down

0 comments on commit 263a2dd

Please sign in to comment.