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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:37:44+00:00 2026-05-23T04:37:44+00:00

I am writing a .NET CIL decompiler (just for fun). I can’t figure out

  • 0

I am writing a .NET CIL decompiler (just for fun). I can’t figure out how to unit test classes in my project that do the actual ‘decompiling’ thing, specifically, the decoders that read a binary file & decode it to meaningful data structures. The approach I came with is to store executable files witch are subject to decoding in the same directory where my test project lies, and just read them in a test’s initialization methods. There are many files, with different file format cases.

That does not really seem elegant. Would it be better to embed this files in the separate resource assembly, or even use fake objects instead, which will return the results I want for every use case? (there are a lot of use cases, so configuring such fake objects will take a lot of time, it is much easier to find executables with specific cases).

And at last, maybe decoders are not something one should unit test?

  • 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-23T04:37:45+00:00Added an answer on May 23, 2026 at 4:37 am

    As far as I understand decoders have pretty complex logic, according to your state that there are a lot of cases in executables. So testing this code is a good idea.

    As you sad we have two options for now: to have a bunch of files for the specific case and to have fake objects emulating each case. Lets review them.

    Having a bunch of files vs building fake objects.

    Once upon a time I’ve spent a huge time thinking about this problem. So lets review some cases I had in my practice and conclusions I made. I’ve had a strong xml parsing logic in one of my projects and I have to choose whether to store xml in xml files, in C# files as string literals or emulate each particular case I need by building XDocument objects. Last approach was killing me, but it looked like “right and elegant”, then I tried to switch to C# string literals and it was also an overkill. It was very hard to edit and understand this huge strings. So I just created xml files and forget about all the problems.

    In the same time in your case it seems that you don’t need to edit binary files very often, but constructing of fake objects will also take a lot of time. And if there is no “cheap” possibility to fake this kind of logic I would suggest to go with files. I also do not suggest to put them in the resources, you will get no benefit for unit test projects from it.

    Another argument. Why we need fake objects? We need them to fake our dependencies and isolate system under test (SUT) from everything that is not related to logic we are testing. Sometimes we have low-level layers in our applications like DB providers or decoders like in your case where using of fake objects will help to test code, but will not help to test code in real-life scenarios. And typically this is solved by covering this low-level layer with slow and comples integration tests. So in your case lets just consider that you are going to write a bunch of Integration Tests for the lowest level of your application witch is okay and elegant approach =) And after doing this you will be ready enought to abstract from this application layer and write fast and again elegant Unit Tests for the rest of you application.

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

Sidebar

Related Questions

I'm writing a .NET web project that prints W2 forms, but I'm not sure
Im writing a .net webforms app. It has a number of classes, for example
I am writing a .NET library that for various reasons cannot be registered in
I'm writing an .NET 3.5 web application that is using LinqToSql for the basic
I am writing a .NET WinForms application that needs to display a list of
I'm writing in .NET a windows service that, at windows startup, executes some network
I'm writing a .NET command-line application that will migrate users from an existing database
I'm writing a .NET program in C# that makes GET requests and downloads pages
I'm writing a .NET application that will make an RPC call to a Java
I'm writing a .NET 4.0 library that should be efficient and simple to use.

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.