The Fixture Gallery is also available as a PDF document and a live FitNesse wiki. See http://gojko.net/fitnesse/fixturegallery for more information.
Previous page: ArrayFixture Next page: ConstraintFixture Parent page: FitLibrary Fixtures

CombinationFixture

CombinationFixture is used to perform an operation on pairs on values. The values are specified in a row and a column and the operation is performed on all combinations of values.

Table Format

The first row of the table is the fixture class name. The second row contains an empty cell followed by cells containing the values to be used as the second parameter for the operation. All subsequent rows contain a value in the first cell to be used as the first parameter for the operation, followed by cells containing the expected value of the operation.

!|CombinationFixtureTest|
|  |1 |2|3|
|6 |6 |3|2|
|12|12|6|4|

Fixture class

The fixture class should extend fitlibrary.CombinationFixture. It should declare a method combine which takes two values (row and column) and returns a value.

Java Source Code

package info.fitnesse.fixturegallery;

import fitlibrary.CombinationFixture;

public class CombinationFixtureTest extends CombinationFixture{
	public int combine(int theFirst, int theSecond) {
		return theFirst / theSecond;
	}
}

.NET Source Code

using fitlibrary;

namespace info.fitnesse.fixturegallery {
	public class CombinationFixtureTest: CombinationFixture {
		public int combine(int theFirst, int theSecond) {
			return theFirst / theSecond;
		}
	}
}

Python Source Code

# PYTHON: info.fitnesse.fixturegallery.CombinationFixtureTest
from fitLib.CombinationFixture import CombinationFixture

class CombinationFixtureTest(CombinationFixture):
    _typeDict = {}

    # PY3K: combine(theFirst : int, theSecond : int) : int
    _typeDict["combine.types"] = [ "Int", "Int", "Int" ]
    def combine(self, theFirst, theSecond):
        return theFirst / theSecond

Smalltalk Source Code

'From VisualWorks®, 7.6 of March 3, 2008 on June 27, 2008 at 3:36:29 pm'!


Info.Fitnesse.Fixturegallery defineClass: #CombinationFixtureTest
	superclass: #{Fitlibrary.CombinationFixture}
	indexedType: #none
	private: false
	instanceVariableNames: ''
	classInstanceVariableNames: ''
	imports: ''
	category: ''!

!Info.Fitnesse.Fixturegallery.CombinationFixtureTest methodsFor: 'accessing'!

combine: aInteger and: bInteger
	^aInteger // bInteger! !

!Info.Fitnesse.Fixturegallery.CombinationFixtureTest methodsFor: 'type access'!

signatureFor: aSymbol
	^MethodSignature with: Integer with: Integer returning: Integer! !

Usage

CombinationFixture can be used to describe calculation rules that depend on exactly two arguments.

Previous page: ArrayFixture Next page: ConstraintFixture Parent page: FitLibrary Fixtures


Personal Tools