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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:34:19+00:00 2026-06-12T01:34:19+00:00

I have this text loader class that I’m trying to write tests for. And

  • 0

I have this text loader class that I’m trying to write tests for. And one of it’s methods does a RaiseEvent with a CancelEventArgs parsed in as an argument, so something like this:

Private Sub FireThisEvent()
    cancelEvent created here
    RaiseEvent HelloWorld(cancelEvent)

    If cancelEvent.Cancel Then
        'do smthg
    End If
End Sub

The handler for HelloWorld event is my UI class that makes a pop-up for the user to
decide Yes or No, which then sets cancelEvent.Cancel to either True or False. And then the above method checks on cancelEvent and does an action accordingly.

My question is, since I’m only testing the loader class (and not the UI), how do I manipulate the cancelEvent after the event is raised so that I can test for when cancelEvent.Cancel is True and then , when it is False. Thank you.

Would I have mock the UI class?

  • 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-12T01:34:20+00:00Added an answer on June 12, 2026 at 1:34 am

    My solution to this was to add an event handler in the test method, so that when the event is raised, the test method will create a CancelEventAgrs and set its Cancel to True/False.

    Public Sub TestingMethod()
            Dim txt As TextLoader = Nothing
            AddHandler TextLoader.LoadingDoneEvent,
                (Sub(e As ComponentModel.CancelEventArgs)
                     e.Cancel = True
                 End Sub)
    
            txt = New TextLoader()
            txt.FireThisEvent()
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this text read into an NSString *responce which I am trying to
I have this input text and input button, I am trying to get them
I have a flex project with a mx:Text. i have a class that is
In my little text game I have an Item class that loads it's objects
I'm pulling my hair out over this one - I have a page that
I have this input text and an input button...I am looking to have them
I have this RTF text: {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}} {\colortbl ;\red0\green0\blue0;\red255\green0\blue0;} \viewkind4\uc1\pard\qc\cf1\fs16 test \b bold \cf2\b0\i
I have this little text <div> Hello world<br> this is a good<br> text! <br><br>
I have got this text file with latitude and longitude values of different points
I have this following jquery text fly-in animation.Here is my code before I explain

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.