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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:25:59+00:00 2026-05-20T15:25:59+00:00

We have a bug to fix, and like any good TDD practitioner, I want

  • 0

We have a bug to fix, and like any good TDD practitioner, I want to write a failing test to represent the bug first. The bug is in a method that takes a rather complex type as input. The bug will only reproduce when the complex type has a certain combination of property values set.

So far I have reproduced the bug and, in the debugger, can view the run-time value of the complex type. Now I need to create that complex type in the “Arrange” section of my unit test so that I can feed it to the buggy method in the “Act” section of the unit test.

I can write a big object initializer code block, by hand, such as the following one:

var cats =
    new List<Cat>
        {
            new Cat {Name = "Sylvester", Age = 8},
            new Cat {Name = "Whiskers", Age = 2}
        };

or even something like this:

var cats = new List<Cat>();
var cat1 = new Cat();
cat1.Name = "Sylvester";
cat1.Age = 8;
cats.Add(cat1);
var cat2 = new Cat();
cat2.Name = "Whiskers";
cat2.Age = 2;
cats.Add(cat2);

Nothing fancy there. The only problem is the “by hand” part — the complex type in my case is not nearly as trivial as the above example.

I can also view the object, while in the debugger, with any of the built-in debugger visualizers. So I figured I would write a custom Debugger Visualizer that will generate the object initialization code for me. To use it, I would reproduce the issue in the debugger, pull up the QuickWatch window and select my custom visualizer.

Another option would be to write a custom serialization implementation that would “serialize” to a block of object initialization code. To use this would be a bit harder than just pulling up the QuickWatch window, but this could work.

Before I tackle this problem myself, has anybody done something like this? Mind sharing a code snippet? Or would anyone suggest another approach?

P.S. In my case, the type of the object is a subclass of an abstract base class. Just wanted to mention 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-20T15:25:59+00:00Added an answer on May 20, 2026 at 3:25 pm

    These suggestions aren’t going to work. Read the first line:

    You can write a custom visualizer for
    an object of any managed class except
    for Object or Array.

    http://msdn.microsoft.com/en-us/library/e2zc529c.aspx

    There is your answer. If I’m reading correctly it can’t be implemented through a visualizer. Sort of lame.

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

Sidebar

Related Questions

Does anyone know of a working fix for the ie z-index bug? I have
I'm trying to fix a bug that I cannot reproduce (yipeee!). I have the
I have had a bug recently that only manifested itself when the library was
EDIT: I have submitted a bug report and Microsoft have acknowledge that it is
I have a interest in a reported bug which Microsoft have made available a
I have a really strange enum bug in Java. for(Answer ans : assessmentResult.getAnswersAsList()) {
I have the following code that shows either a bug or a misunderstanding on
This is a registered bug ( Bug ID: 6515708 ) but does anyone have
I have this form in my view: <!-- Bug (extra 'i') right here-----------v -->
We user JIRA for bug tracking and release management and we have started using

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.