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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:50:38+00:00 2026-06-09T13:50:38+00:00

for testing purposes, I need to override a specific method call, which is currently

  • 0

for testing purposes, I need to override a specific method call, which is currently implemented in a base class.

 Public Overridable Function CreateFactory(Of TFactory As {IManagerFactory(Of IManager), Class})() As TFactory

I want to avoid having to create an inheriting class for each existing subclass of that base class (ie. CLTestableAccountManager for CLAccountManager which inherits from CLBase etc.).

Public Class CLTestableAccountManager
  Inherits CLAccountManager

    Public Overrides Function CreateFactory(Of TFactory As {IManagerFactory(Of IManager), Class})() As TFactory

While this works, it would lead to a lot of duplicated code due to the many classes this would apply to.
The method must only be overridden when used in the context of unit tests so I shouldn’t really touch the base class implementation (which is virtual/overridable).

Unfortunately, I cannot simply do something like

Public Class CGenericBaseOverrider(Of TBase As {CLBase})
  Inherits TBase

to implement a generic way for overriding the method for all subclasses of CLBase.

Can anyone point me in a direction as to how this could be solved?

  • 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-09T13:50:39+00:00Added an answer on June 9, 2026 at 1:50 pm

    Can you use composition instead of inheritance?

    In other words, for testing purposes create a type which implements the same interface (introduce an interface if you don’t have one) and delegates all the calls apart from CreateFactory to whatever production code you’ve got – but performs your custom behaviour for that one call.

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

Sidebar

Related Questions

For testing purposes of a RandomGen -reliant function I need a RandomGen instance which
I need a mock implementation of a class - for testing purposes - and
For testing purposes I need a function like this: /** * @param int $sizeInBytes
For testing purposes, I need to share some definitions between Tcl and C. Is
Declaring a class for (fast) testing purposes is great: require 'fast_helper' require 'site_search' class
For testing purposes, I need to find two 64-bit integer values that exactly multiply
I need few Wordpress sites for testing purposes. It would be great if I
For testing purposes, I want to be able to create cookies as I need
For testing purposes I need strings such as: test\x00string I would like to loop
I have this code. It's just for testing purposes, so you don't need to

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.