Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8138105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:23:28+00:00 2026-06-06T11:23:28+00:00

I have the following test case in my iOS application : -(void) testTwoDefaultUsersExist {

  • 0

I have the following test case in my iOS application :

-(void) testTwoDefaultUsersExist
{
NSString * expected;
NSString * actual;

expected = @"John Smith";
actual = [[[userService getAllUsers]objectAtIndex:0] fullName];
STAssertEqualObjects(expected, actual, @"Not equal");
expected = @"Dave Brown";
actual = [[[userService getAllUsers]objectAtIndex:1] fullName];
STAssertEqualObjects(expected, actual, @"Not equal");
}

The above just checks that my call to [userService getAllUsers] returns 2 User objects, one with a name of John Smith, the other with Dave Brown. This appears to work fine for this scenario, but I have other cases where that ordering may change, so John may be placed in index 1 rather than 0

Question : How can I assert that the NSMutableArray, being returned from the call to [userService getAllUsers] contains those 2 objects, regardless of ordering?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:23:29+00:00Added an answer on June 6, 2026 at 11:23 am

    Can you not simply use the NSArray method -containsObject:? An NSMutableArray is still an NSArray, so you can do:

    NSArray * expected = [NSArray arrayWithObjects:@"John Smith", @"Dave Brown", nil];
    NSArray * actual = [[userService getAllUsers] valueForKey:@"fullName"];
    for(NSString * name in expected) {
        STAssertTrue([actual containsObject:name], @"Missing name");
    }
    

    Note the (ab)use of -valueForKey: to transform an array of user objects into an array of NSString objects, making the -containsObject: call simpler. This will only work if your user object is key-value coding compliant for the fullName property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following test case [TestMethod()] [DeploymentItem(Courses.sdf)] public void RemoveCourseConfirmedTest() { CoursesController_Accessor target
I have the following test case: @ContextConfiguration(/spring/test-context.xml) @TransactionConfiguration(transactionManager=txManager) @Transactional() public class MyEntityDaoTestCase extends AbstractJUnit4SpringContextTests
I have the following code in test.sh: while getopts f:i: opt; do case $opt
I have the following django test case that is giving me errors: class MyTesting(unittest.TestCase):
I have the following string - Default (45-889) %69 (Test Case)-1/24/2012 12:16:01 AM-1/24/2012 12:16:11
I have the following code in a test case on jsPerf: var arr =
I am using Linq to NHibernate. I have a following test case : [TestMethod]
I have the following test case in eclipse, using JUnit 4 which is refusing
I got following test case below and have a question to it. Why does
I have the following test case: DROP SCHEMA IF EXISTS test CASCADE; CREATE SCHEMA

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.