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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:04:04+00:00 2026-06-11T18:04:04+00:00

Here is a part of a code of a simple WPF application: 3 textboxes,

  • 0

Here is a part of a code of a simple WPF application: 3 textboxes, a dropdownList and a button. By clicking a button, there will be checking of input values.

   private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        if (textBox1.Text.Length>127)
            throw new ArgumentException();
        if (string.IsNullOrEmpty(textBox2.Text))
            errorsList.Add("You must to fill out textbox2");
        else if (string.IsNullOrEmpty(textBox3.Text))
           errorsList.Add("You must to fill out textbox3"); 
       else if
        {
            Regex regex = new Regex(@".........");
            Match match = regex.Match(emailTxt.Text);
            if (!match.Success)
                errorsList.Add("e-mail is inlvalid");
        }
        //.....
     }

I have to test it by using any Unit testing Framework. I wonder is it possible to do Unit testing here? I guess it is not, right?

  • 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-11T18:04:05+00:00Added an answer on June 11, 2026 at 6:04 pm

    It is not possible to unit test the current code you have without refactoring. You should encapsulate that logic in a ViewModel class. I guess you can have something like

    DoTheJob(string1,string2,string3,...)
    

    and error/errorList/exList as ObservableCollections into the viev model too.
    With these precondition you can write a suite of unit tests checking your code behavior.

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

Sidebar

Related Questions

Just putting part of some code here where I am writing two values to
Really struggling with this simple code here. I'm checking if the section with #setactionsuccess
Here's part of my code for a jQuery word counter. My question is: how
I need a fix for this. here is just part of my code <?php
Here is a part of my html code (video urls marked with a django-template
Here is the first part of my controller code: public class ControlMController : Controller
The following code is taken from here . I removed all Windows NT part
Here is part of my web.xml: <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:application-config.xml </param-value> </context-param> application-config.xml uses
I need to implement a small part of my application logic in native code.
I am trying to get a simple VBA code as part of a Macro

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.