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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:21:21+00:00 2026-05-17T22:21:21+00:00

I am developing one Windows phone 7 application. It has another project for unit

  • 0

I am developing one Windows phone 7 application. It has another project for unit testing. Now in the main application I have one method that executes some code to navigate to another page. While unit testing I don’t want that method to execute and just return in the first line. Right now how I am doing it is defining a symbol while unit testing.

#define EnableUnitTest


public static void Navigate(string page)
{

 #if EnableUnitTest
     return;
 #endif
  .....
  .....       

}

Is there a better way of doing it.

  • 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-05-17T22:21:22+00:00Added an answer on May 17, 2026 at 10:21 pm

    Sorry to say it but that seems like a very bad design. In a unit test you are testing some code which shouldn’t be conditioned that way. A unit test should consist of three steps: Arrange, Act, Assert where you prepare the input, call the actual method and assert the results. It’s in the arrange step that you should prepare the method under test.

    Also I notice that this method is static. Static methods are difficult to unit test. It would be better to abstract the logic of this class into an interface or abstract base class which could be easily mocked/stubbed in a unit test to weaken the coupling between the different parts of your code.

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

Sidebar

Related Questions

I'm developing a small utility application that needs to detect whether another one has
I am developing iPhone application and In that application I've one TableViewController , and
I have an urgent problem..I am developing a windows mobile 6.0 application and the
I'm developing a Mac App in Java that logs into any one of our
What are profound advantages that one get when using COM for developing components over
When developing an app that will listen on a TCP/IP port, how should one
I know someone who has a one-man company developing applications in Delphi and Pascal.
Anyone know application like network location(mac) for linux,windows.If not i am thinking of developing
I am developing a program which sends images from one computer to another (similar
We're developing a large desktop application using Windows Presentation Foundation. Currently, the application is

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.