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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:00:45+00:00 2026-05-19T16:00:45+00:00

I would like to write a callable function that accepts two objects, and compares

  • 0

I would like to write a callable function that accepts two objects, and compares 30+ properties of those objects with asserts. The issue is this needs to be done for about 20 existing unit tests and most future tests, and writing out the 30+ asserts each time is both time and space consuming.

I currently have a non unit test function that compares the objects, and returns a string with “pass” or a failure message, and use an assert to validate that in each unit test. However, its quite messy and I feel like I’m going against proper unit testing methods.

Is there a way to make a function that is callable from inside unit tests that uses asserts to check conditions?

  • 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-19T16:00:46+00:00Added an answer on May 19, 2026 at 4:00 pm

    To answer the final part, you can of course have Asserts inside another function. Asserts work by raising exceptions which the test runner catches, and interprets as a failure, so have a Test like so will work fine:

    public void CheckAsserts(string value)
    {
        Assert.IsNotNull(value);
    }
    
    [TestCase("yes!")]
    public void MyTest(string value)
    {
        CheckAsserts(value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to write some functions that take a single parameter which could
I would like to write a program or script that would generate .vcproj and
I would like to write SQL query for finding the node ID (nid) for
I would like to write a setup script for my PHP application, which dose
I would like to write a program using tilting functionality in android. Is there
I would like to write a 2D real time strategy game probably using XNA
I have a free web site that streams real-time stock-options data. I want to
I use asp.net, c# and EF4. I'm puzzled by this LINQ query: var queryContents
I'm writing a database browser application with PyQt4 and because I'm new to Qt,
Is it possible to place a title on the left (or right) of a

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.