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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:30:52+00:00 2026-05-11T19:30:52+00:00

My intend is to create a simple easily debuggable console application which will be

  • 0

My intend is to create a simple easily debuggable console application which will be the template ( or starting point ) for test driven developing single classes in C#. The purpose is to have a simple folder where this console app will reside and just copy paste the folder open the new project and start writing the new class. As soon as the class all functionalities tested ( Preferably the tests should be in the same file ( or at least namespace ) the class will be allowed to go into the larger project. I am using NUnit and log4net. If you do you this kind of “small test driven unit building ” approach how have you implemented it. Please, post some code or explanation. If you do not use, please provide explanation why?
Here is the code ( the config data is also pasted as comments … )

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using log4net.Config;
using NUnit.Framework;

namespace NUnitSimple
{

  class TheClassToTest_Substractor
  {

    private static readonly ILog logger =
         LogManager.GetLogger ( typeof ( TheClassToTest_Substractor ) );



    public static void Substract ( int intToSusbractFrom , int intToSubstract , ref int intTheResult)
    {
     intTheResult = intToSusbractFrom - intToSubstract ; 
    }


    static void Main ( string[] args )
    {
      DOMConfigurator.Configure (); //tis configures the logger 


      logger.Info ( " START " );
      logger.Info ( " Hit a key to exit " );
      Console.ReadLine ();


    } //eof method 



  } //eof class 

  [TestFixture]//telling NUnit that this class contains test functions 
public class TestTheClassToTest_Substractor
{ 

     [Test]//telling NUnit that this function should be run during the tests 
    public void TestSubstractOk() 
    { 
       int intToSusbractFrom = 10 ; 
       int intToSubstract = 4 ; 
        int intTheResult = 0 ;
       TheClassToTest_Substractor.Substract ( intToSusbractFrom , intToSubstract , ref intTheResult ) ;
        Assert.AreEqual (  6 , intTheResult);
    }



     [Test]//telling NUnit that this function should be run during the tests 
     public void TestSubstractNOK ()
     {
       int intToSusbractFrom = 10;
       int intToSubstract = 4;
       int intTheResult = 0;
       TheClassToTest_Substractor.Substract ( intToSusbractFrom, intToSubstract, ref intTheResult );
       Assert.AreNotEqual ( 3, intTheResult );
     }

} //eof class 


} //eof namespace 




#region TheAppConfig
/*
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="log4net"
         type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
  <log4net>
    <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
      <param name="File" value="Program.log" />
      <param name="AppendToFile" value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <param name="Header" value="[Header] \r\n" />
        <param name="Footer" value="[Footer] \r\n" />
        <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
      </layout>
    </appender>

    <appender name="ColoredConsoleAppender" type="log4net.Appender.ColoredConsoleAppender">
      <mapping>
        <level value="ERROR" />
        <foreColor value="White" />
        <backColor value="Red, HighIntensity" />
      </mapping>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>


    <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
      <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.2.10.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionString value="data source=ysg;initial catalog=DBGA_DEV;integrated security=true;persist security info=True;" />
      <commandText value="INSERT INTO [DBGA_DEV].[ga].[tb_Data_Log] ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)" />

      <parameter>
        <parameterName value="@log_date" />
        <dbType value="DateTime" />
        <layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}" />
      </parameter>
      <parameter>
        <parameterName value="@thread" />
        <dbType value="String" />
        <size value="255" />
        <layout type="log4net.Layout.PatternLayout" value="%thread" />
      </parameter>
      <parameter>
        <parameterName value="@log_level" />
        <dbType value="String" />
        <size value="50" />
        <layout type="log4net.Layout.PatternLayout" value="%level" />
      </parameter>
      <parameter>
        <parameterName value="@logger" />
        <dbType value="String" />
        <size value="255" />
        <layout type="log4net.Layout.PatternLayout" value="%logger" />
      </parameter>
      <parameter>
        <parameterName value="@message" />
        <dbType value="String" />
        <size value="4000" />
        <layout type="log4net.Layout.PatternLayout" value="%messag2e" />
      </parameter>
    </appender>
    <root>
      <level value="INFO" />
      <appender-ref ref="LogFileAppender" />
      <appender-ref ref="AdoNetAppender" />
      <appender-ref ref="ColoredConsoleAppender" />
    </root>
  </log4net>
</configuration>
 */
#endregion TheAppconfig

#region TheXmlReferingToTheNUnitAndLog4NetInNUnitSimple.csprojFile
/*
     <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\Log4Net\log4net-1.2.10\bin\net\2.0\release\log4net.dll</HintPath>
    </Reference>
    <Reference Include="nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
 */
#endregion
  • 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-11T19:30:53+00:00Added an answer on May 11, 2026 at 7:30 pm

    Rather than set up a a project and then cut and paste, why not look at a script tool like Tree Surgeon to set up a project structure. This will set up your solution, projects and project folders. It includes functionality for both nUnit and nAnt.

    Be sure to look at the blog posts mirrored at the bottom of the project home page.

    BTW: I agree with Jon Skeet on console apps. They can be useful, but if you have a tool like TestDriven.Net for VS.2005 and earlier, or the VS.2008 testing tools, you can step into your test code without creating your own harness app.

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

Sidebar

Ask A Question

Stats

  • Questions 160k
  • Answers 160k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You shouldn't re-reference b in the subquery: delete taskperformance@dm_prod b… May 12, 2026 at 11:40 am
  • Editorial Team
    Editorial Team added an answer You are going to laugh, but it's just slightly different… May 12, 2026 at 11:40 am
  • Editorial Team
    Editorial Team added an answer I wrote up an introduction to URL Rewriting in ASP.NET… May 12, 2026 at 11:40 am

Related Questions

My compilers class is creating a language that we intend to compile to Java
I've created a question about this a few days . My solution is something
I need to create a user control, that will be used in an application
I want to create a function that can take different types of iterators which

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.