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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:25:10+00:00 2026-06-08T14:25:10+00:00

How should the following method be unit tested? /// <summary> /// Entry point for

  • 0

How should the following method be unit tested?

    /// <summary>
    /// Entry point for GUI thread.
    /// </summary>
    public void VerifyDataTypesAsync()
    {
        Task verificationTask = Task.Factory.StartNew(() =>
        {
            VerifyDataManagerAsync();
        });
    }

is it only possible to test via integration testing or is it possible to test that a task was created?

Thanks for your help

  • 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-06-08T14:25:11+00:00Added an answer on June 8, 2026 at 2:25 pm

    You can create a Factory for creating this task and use it through seams. You can use property seam – it is when you set the instance of your factory to a property of an under test class or you can use constructor seam by giving the factory through a constructor. Then you can mock this factory and set it through one of two seams and check does your VerifyDataTypesAsync method call the method of creating your task.

    class YourClass
    {
        public YourClass(ITaskFactory factory)
        {}
    
        public void VerifyDataTypesAsync()
        {
           Task verificationTask = factory.Create(); // you can pass an instance of a delegate as parameter if you need.  
        }
    }
    
    class TasksFactory : IFactory
    {
       public Task Create()
       {
    
       }
    }
    

    Then in your test you can create a mock object of IFactory and pass it to the constructor of your class then set mock rules for mock to check if the method Create was called.

    If we are talking about NUnit and RhinoMocks it can be looked about this:

    var mockRepository = new MockRepository();
    var mockObject = mockRepository.CreateMock<IFactory>();
    var yourClass = new YourClass(mockObject);    
    
    
    Expect.Call(mockObject.Create);
    
    mockRepository.ReplayAll();
    
    mockObject.VerifyDataTypesAsync()
    
    mockRepository.VerifyAll(); // throw Exception if your VerifyDataTypesAsync method doesn't call Create method of IFactory mock
    

    roughly speaking like this… but it is just one way…

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

Sidebar

Related Questions

I want to unit test following method public void addRecord(Record record) { Myclass newObj
I have the following application_controller method: def current_account @current_account ||= Account.find_by_subdomain(request.subdomain) end Should I
I have following spec to test controller method: context #create do it should redirect
Trying to write Unit test for Silverlight 4.0 using Moq 4.0.10531.7 public delegate void
Another day , another question. My service layer has the following method public MatchViewData
I have the following method: class MyClass { public: MyClass; bool method (MyClass &obj);
The following should find me the elector ID and the date. For some reason
Can anyone tell me what the result to the following should be according to
I am making a game. The following should draw me a picture of c.png
The following selects should be mandatory: <select id=area class=input-xlarge> <option value=0 selected=selected></option> <option value=A>A</option>

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.