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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:53:52+00:00 2026-05-12T16:53:52+00:00

I have a bunch of unit tests that work on a class which executes

  • 0

I have a bunch of unit tests that work on a class which executes some tasks asynchronously. Currently I set up the class, then execute the function in question. I then go into a blocking wait until the execution is completed, then test the data I need to. Is there a better way that I can do this?

So far my tests look similar to this:

    vp.Reset(); //vp is my virtual machine
    bool wait = true;
    Dictionary<short, Command> commands = new Dictionary<short, Command>();
    commands.Add(0, CommandFactory.CreateInputCommand(0, 0));
    commands.Add(1, CommandFactory.CreateHaltCommand());
    vp.OnHalted += () =>
    {
        wait = false;
    };
    vp.InputChannels[0] = () => { return 2; };
    vp.CurrentProgram = commands;
    vp.ExecuteTillHalt();//asynchronous execution of program. There's also a way to make it execute synchronously
    while (wait) ;
    Assert.AreEqual(vp.Registers[0], 2);
  • 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-12T16:53:52+00:00Added an answer on May 12, 2026 at 4:53 pm

    I see two tests, one to test that an asychronous action is launched (which can be done with a mock) and the second to test that the action that is run asychronously performs correctly when run and you can do the latter synchronously.

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

Sidebar

Related Questions

I have a whole bunch of unit tests written in MbUnit and I would
Visual Studio 2010 generated a bunch of unit tests for me which seems to
I have a bunch of repository classes which I want to unit-test using Visual
In one of our service classes I have a bunch of methods which just
We have a build machine running in our development department, which we've set up
I have a bunch of Python modules I want to clean up, reorganize and
The title says it - What happens between TestMethods in MS Visual Studio Unit
I'm using VS2008 Pro and as such my c# project includes a bunch of
Are there any technical Design-by-Contract solutions for Java projects similar to XINS ? I'm
When I am working with a VS 2008 Team System solution with a very

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.