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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:12:04+00:00 2026-05-22T21:12:04+00:00

I have a logic module for a turn based game (no UI yet), which

  • 0

I have a logic module for a turn based game (no UI yet), which uses async user input (parsed from console, until the real UI gets done), and in some cases generates random numbers (“die rolls”) and makes changes in the game state-model based on the inputs and the random numbers.

Reading this thread and this thread, I was wondering if it was possible to use something similiar. My game logic has a single Random instance, so it should be relatively easy to swap that out.

So what do I have to do?

  • Swap out GameLogic.Random to an IRandom, and put either a Random or a pregenerated sequence into it based on whether I’m testing
  • Swap out Console.ReadLine() with IConsole.ReadLine() everywhere in my command parser so I don’t have to type it in every time
  • Swap out Console.WriteLine() with IConsole.WriteLine() so it prints to a file, where I can read the results

And then I can use my classes from a Unit Test? That’s all??

  • 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-05-22T21:12:04+00:00Added an answer on May 22, 2026 at 9:12 pm

    Yes, that’s all, but you don’t even have to do that, if you don’t want to.

    You don’t have to create the interface IConsole, because in a way, it already exists. You can use TextReader for your input and TextWriter for your output. In real app, you pass in Console.In and Console.Out. In testing you can use StringReader and StringWriter.

    You also don’t have to create IRandom if you don’t want to supply the numbers yourself and Random initialized to a constant seed is enough for you.

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

Sidebar

Related Questions

I have some logic, which defines and uses some user-defined types, like these: class
I have authentication logic that uses cookies. The model attributes are initialized from cookies,
I have been given a new project module which involves fuzzy logic. It is
Hi we have made a module for a controller and that module uses the
My application is written in C. I have a module that uses some data
I have a logic module that tells a supervisor to start child processes. I
Why do i have to use some persistent-login module to make my users login
Currently, in my settings module I have this: LOGIN_URL = '/login' If I ever
I'm sure you've all seen them. Line of Business UIs that have logic such
I have some logic in a method that operates on a specified type and

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.