Port of schuchert.wikispaces.com


FitNesse.Tutorials.0.CSharp

FitNesse.Tutorials.0.CSharp

Create C# Project

In a nutshell, you are going to create a C## project, add some classes and then add the DLL to the FitNesse path so that FitNesse can find and execute your C# Fixtures.

Create Fixture to back Test Table

Determine Where Visual Studio Stores Your Generated DLL

Update Page to have NSlim Configuration

!define TEST_SYSTEM {slim}

!define COMMAND_PATTERN {%m -r fitSharp.Slim.Service.Runner,c:\tools\nslim\fitsharp.dll %p}

!define TEST_RUNNER {c:\tools\nslim\Runner.exe}
!|import|
|DigitalVideoRecorder|

Add your code to Path

!path C:\Projects\C_Sharp\DigitalVideoRecorder\DigitalVideoRecorder\bin\Debug\DigitalVideoRecorder.dll
!define TEST_SYSTEM {slim}

!define COMMAND_PATTERN {%m -r fitSharp.Slim.Service.Runner,c:\tools\nslim\fitsharp.dll %p}

!define TEST_RUNNER {c:\tools\nslim\Runner.exe}

!path C:\Projects\C_Sharp\DigitalVideoRecorder\DigitalVideoRecorder\bin\Debug\DigitalVideoRecorder.dll

!define COLLAPSE_SETUP {true}
!define COLLAPSE_TEARDOWN {true}

!|import|
|DigitalVideoRecorder|
 
!|Create Programs|
|Name|Channel|DayOfWeek|TimeOfDay|DurationInMinutes|id?|
|House|4|Monday|19:00|60|$ID=|

You have two tables in your page. The first table is an import table, it tells FitNesse to import that namespace (i.e. like using in .Net). That is, when looking for fixture classes (classes that process tables), look in this namespace. If you want to import multiple namespaces, use multiple rows (or duplicate the entire table).

The second table is a decision table. (Those familiar with Fit, may recognize the similarity between Decision Tables and Column Fixtures.) The first row names a class, CreatePrograms in this case. You created this class above. The second row names the columns. Column headers that do not have a question mark in their name require a “set” method to back them. Column headers with a question mark require a method that returns a value. In our case we have 6 columns, so we need to add 6 methods, 5 setters and one method which returns a value. Here’s the complete “stub” class to get this table fully passing:

using System;

namespace DigitalVideoRecorder
{
  public class CreatePrograms
  {
    private string _name;
    private int _channel;

    public void setName(String name)
    {
      _name = name;
    }

    public void setChannel(int channel)
    {
      _channel = channel;
    }

    public void setDayOfWeek(String dayOfWeek)
    {
    }

    public void setTimeOfDay(String timeOfDay)
    {
    }

    public void setDurationInMinutes(int durationInMinutes)
    {
    }

    public string id()
    {
      return String.Format("[{0}:{1}]", _name, _channel);
    }
  }
}

Verify Your Tests Pass

Return and Complete Your Tutorial


Comments

" Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.