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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:27:31+00:00 2026-06-14T11:27:31+00:00

I have a problem with Visual Studio 2012 unit testing, more precisely – with

  • 0

I have a problem with Visual Studio 2012 unit testing, more precisely – with code coverage.
Here is a target code:

var someDeals = allDeals
            .Where(i => i.Number != null && !i.Number.StartsWith(SomeString))
            .Select(i => new DealInfoDto
            {
                CurrentDebtAmount = i.CurrentDebtAmount,
                Date = i.Date,
                NextMonthlyPaymentDate = i.NextMonthlyPaymentDate,
                Number = i.Number,
                AccountNumber = i.AccountNumber,
            })
            .ToArray();

When I run analyze code coverage it shows me that lambda expression in second line (i.Number != null && !i.Number.StartsWith(SomeString)) is partially touched area and I can’t get 100% coverage. But I’m sure that this expression is evaluated (expression inside SELECT is OK, so expression inside WHERE is true and that’s mean that both parts of && statement were touched, also I’ve checked data and I’m sure that i.Number != null and !i.Number.StartsWith(SomeString).

Why this block is not covered?

P.S. I splitted Where into two expressions and everything became OK. But it looks smth ugly and would be better just one Where:

allDeals
    .Where(i => i.Number != null)
    .Where(i => !i.Number.StartsWith(CardAccountIdentifier))
  • 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-14T11:27:33+00:00Added an answer on June 14, 2026 at 11:27 am

    This question looks very similar to MSTest Shows Partial Code Coverage on Compound Boolean Expressions.

    What I suspect is happening is that you are not testing the early fail path when i.Number is null.

    If you remember && will only evaluate the second expression if the first was true. In your case I suspect (as you haven’t mentioned how or what your tests are) that you do not have a test or scenario where there is an entry in your allDeals collection where i.Number is null.

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

Sidebar

Related Questions

I have a problem of installing Visual Studio Service Pack 1. Error Code 13EC.
I have the most annoying problem with Visual Studio 2012 and WPF I was
I have a problem establishing connection with Server Explorer in Visual Studio 2012 Ultimate
Enviroment: Visual Studio 2012, MVC4, Razor, Internet Application. I have a code with search
I have a problem with the Visual Studio 2012 implementation of the std::thread class.
I'm writing an app in Visual Studio C++ and I have problem with assigning
I have a problem with SHGetFolderPathA in Visual Studio 2010 (Windows Forms). I included
I have had a persistent problem with Visual Studio 2010 and any framework version
I have this problem where I open Visual Studio and the internal windows are
I have a problem debugging Invoke() or BeginInvoke() in Visual Studio 2008. For instance

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.