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

  • SEARCH
  • Home
  • 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 8456813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:38:42+00:00 2026-06-10T12:38:42+00:00

in a test I need to test an object: IEnumerable<int> Ids. The collection contains

  • 0

in a test I need to test an object:

IEnumerable<int> Ids.

The collection contains the numbers 1,2 and 3.

I basically wanted to test that there are three ids in Ids and that 1,2 and 3 are all present.

The problem is there isn’t a count on IEnumerable.

I thought I was going to be able to go:

Assert.AreEqual(3, Ids.Count);

Anyone know how to do this and how to ensure 1,2 and 3 are the actual numbers in there?

  • 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-10T12:38:43+00:00Added an answer on June 10, 2026 at 12:38 pm

    You can use LINQ extension methods for these needs:

    using System.Linq;
    
    …
    
    Assert.AreEqual(3, Ids.Count());
    
    Assert.IsTrue(Ids.Contains(1));
    //etc.
    

    If you want to have exactly the same items in exactly the same order, there is also:

    Assert.IsTrue(Ids.SequenceEqual(new List<int>{ 1, 2, 3 }));
    

    Ordering is not guaranteed according to the semantics of IEnumerable<T>, but that may not be of consequence in your particular scenario.

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

Sidebar

Related Questions

In JUnit tests, I need to test that a given object (not the reference,
I need to test a controller, of action index (generated by the grails generate-all
I have a method that uses setAttribute on the Request object. I need to
I need to test whether the object is of type NSString or UIImageView .
I am trying to write a test and need to create a Message object
Ola, Android/JAVA question, I need to test if a object is not NULL and
I have this function that returns an object: String.prototype.test = function(a,b){ var ob =
I need to test my REST API backend that accepts JSON with the Advanced
I need to test for placeholder support. The following works great in all modern
I have the following class structure that I need to unit test: public interface

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.