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.
- Start Visual Studio
- Create a new Project (File:New:Project:Visual C#:Class Library) (I used C:\Projects\C_Sharp for the directory, Digital Video Recorder for the Name and Solution Name)
Create Fixture to back Test Table
- Visual Studio creates a class called Class1.cs in the namespace DigitalVideoRecorder by default, rename Class1.cs to CreatePrograms.
- Remove all of the using statements automatically inserted by Visual Studio
- Save and build your solution.
Determine Where Visual Studio Stores Your Generated DLL
- The DLL should be under the bin\Debug directory. In my case, the full path to my DLL is:
C:\Projects\C_Sharp\DigitalVideoRecorder\DigitalVideoRecorder\bin\Debug
Update Page to have NSlim Configuration
- Add the required configuration to the top of your DigitalVideoRecorder page:
- Add an import table so FitNesse will find the class in its namespace (above the Create Programs Table):
Add your code to Path
- Edit your page and add the following lines (above the table that is already there):
- Your page should now be:
- Click on the Test button, you should see some green and red now:
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:
- Edit your CreatePrograms class and add the missing methods.
- Notice that the implementation of id() returns a String with the name and channel. As you’ll see, this value will show up later.
- Make sure to build your project.
Verify Your Tests Pass
- Switch back to your browser, click on the Test button. You should see something similar to this:
Comments