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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:13:30+00:00 2026-06-04T21:13:30+00:00

Just an example: I have a class that reacts to set properties. More specifically,

  • 0

Just an example: I have a class that reacts to set properties. More specifically, there are three properties from which an assembly is loaded once they are all set. Afterwards an event is triggered.

My unit test for this behavior look something like this:

bool assemblyLoaded = false;
loader.AssemblyLoaded += () => assemblyLoaded = true;
loader.Type = "someType";

Assert.IsFalse(assemblyLoaded); // not loaded, only one property was set

This would lead to three unit tests, one test for each property. So I’d like to abstract the test by using a helping method (see below) to avoid code replication:

private void Testfoobar(Action setProperty)
{
    bool assemblyLoaded = false;
    loader.AssemblyLoaded += (sender, args) => assemblyLoaded = true;
    setProperty();
}

Unfortunately, I cannot make a property assignment an Action.

So, I wonder, can you somehow “transform” the assignment to Action? Or is there maybe a different way to abstract the code?

  • 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-04T21:13:32+00:00Added an answer on June 4, 2026 at 9:13 pm

    What do you mean when you say you cant make a property assignment an Action?

    That you cant implement the assignment in action?

    Why cant you use

    Action<loader> action =(loader)=>loader.Type="someType";
    

    If you want to do it with delegate, you can use the Funct<> delegates:

    Func<string> funct = ()=>"someType";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started using Qt and noticed that all the example class definitions have
Lets say, for example, that I have a class that requires the use of
Say as an example I have a Player class that has a race via
I have a class that has a dozen or so properties that represent various
Just wondering how people would go about this. Say I have one class that
Let's say for example I have a class A that creates an instance of
I have a class that uses either a static list (firstFriend in the example)
I have a class that has some properties. And I want something that calculates
Let's say I have a class that has a member called data which is
Just for example I have next NSDictionary { { first_name = Paul; last_name =

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.