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 8704859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:13:05+00:00 2026-06-13T03:13:05+00:00

From Microsoft’s documentation, partially covered code is …where some of the code blocks within

  • 0

From Microsoft’s documentation, partially covered code is “…where some of the code blocks within the line were not executed.” I’m pretty stumped on this one (simplified for brevity):

Given this method:

public List<string> CodeUnderTest()
{
    var collection = new List<string> { "test1", "test2", "test3" };
    return collection.Where(x => x.StartsWith("t") && x == "test2").ToList();
}

And this test:

[TestMethod]
public void Test()
{
    var result = new Class1().CodeUnderTest();
    CollectionAssert.Contains(result, "test2");
}

Code coverage results shows that the expression x.StartsWith("t") && x == "test2 is only partially covered. I’m not sure how that’s possible unless the compiler or CLR has some sort of eager condition matching stuff, but maybe I just need to have it explained.

  • 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-13T03:13:07+00:00Added an answer on June 13, 2026 at 3:13 am

    The conditional-AND operator (&&) performs a logical-AND of its bool operands, but only evaluates its second operand if necessary.

    http://msdn.microsoft.com/en-us/library/2a723cdk(v=vs.100).aspx

    so you would expect both sides to be covered

    perhaps what it is complaining about is that you haven’t tested the -ve paths i.e. if your collection is

    var collection = new List<string> { "test1", "test2", "test3", "not_this_one" };
    

    this way you test the x.StartsWith("t") being T/F because currently only the T path is being tested for that condition.

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

Sidebar

Related Questions

I found some examples from Microsoft , but I'm not sure how to get
following some example from Microsoft I created my custom MembershipProvider in my MVC application
I am trying to use the code from Microsoft for an Async Socket connection.
Taken from Microsoft documentation: By default, the thread pool has 250 worker threads per
How do I debug Matlab code called from Microsoft Excel? Is there a way
I'm trying to use this sample code from Microsoft to determine what encoder options
I'm following this ASP.NET MVC tutorial from Microsoft : My code is slightly different,
How to Read word comments (Annotation) from microsoft word document ? please provide some
When I try to port my Win32 code from Microsoft toolchain to MinGW, most
I have got this read file code from microsoft @C:\Users\computing\Documents\mikec\assignment2\task_2.txt That works fine when

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.