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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:59:46+00:00 2026-06-01T04:59:46+00:00

In brief: What is the pattern called in the following code, and how should

  • 0

In brief: What is the pattern called in the following code, and how should it be tested?

The purpose of the code is to encapsulates a number of actions on a zip file (written in C#, although the pattern is language independent):

public class ZipProcessor
{
    public ZipProcessor(string zipFilePath) { ... }

    public void Process()
    {
        this.ExtractZip();
        this.StepOne();
        this.StepTwo();
        this.StepThree();
        this.CompressZip();
    }

    private void ExtractZip() { ... }
    private void CompressZip() { ... }
    private void StepOne() { ... }
    private void StepTwo() { ... }
    private void StepThree() { ... }
}

The actual class has around 6 steps, and each step is a short method, 5-15 lines long. The order of the steps is not important, but Extract and Compress must always come first and last respectively. Also, StepTwo takes much longer to run than the rest of the steps.

The following are options I can think of for testing the class:

  • Only call the public Process method, and only check the result of one step in each test method (pro: clean, con: slow, because each test method calls StepTwo, which is slow, even though it doesn’t care about the result of StepTwo)
  • Test the private steps directly using an accessor or wrapper (pro: simple, clear relation to what is run during a test and what is actually tested, con: still slow: extracts and compresses multiple times, hacky: need to use a private accessor or dynamic wrapper, or make the steps internal in order to access them)
  • Have only one test method that calls a bunch of smaller helper test methods (pro: fast, models the class more closely, con: violates “one assert per test method”, would still need to run multiple times for different scenarios, ex. StepOne has different behavior based on input)
  • 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-01T04:59:47+00:00Added an answer on June 1, 2026 at 4:59 am

    There’s not really a pattern reflected here, but you could rewrite your code to use the Strategy or Chain of Responsibility patterns, as pointed out Paul Michalik. As is, you basically just have a custom workflow defined for your application’s needs. Using the Chain of Responsibility pattern, each step would be its own class which you could test independently. You may want to then write an integration test which ensures the whole process works end-to-end (component or acceptance level test).

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

Sidebar

Related Questions

After a relatively brief text on Haskell wiki about pattern matching of records, I'm
Brief synopsis, this code works beautifully and does what it is supposed except with
Hi I was tasked with building an app with the following brief. Implement an
Brief version of my question: This code crashes the compiler. pThread[0] = new boost::thread(
Brief blurb, My skill in .net has been called innovative but I would prefer
Brief Description of the app: I have written a Delphi application that allows a
EDIT: See my working code in the answers below. In brief: I have a
Brief : I have code which works if I don't dispose of the BindingSource
Brief background: I have two-step login page, which after step 1 sends one-time code
Summary: I have a struct that is read/written to file. This struct changes frequently,

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.