Skip to content
msuarz edited this page Jan 24, 2013 · 8 revisions

Let's suppose we have a fancy Calculator
So fancy that it is implemented in C#
We could write the regular docs

Fancy Calculator

It can do stuff like

2 + 2 = 4
4 - 2 = 2

Steps

require 'csharp'
using 'Math.Calculator'

class @Calculator

  constructor: ->
    @calculator = new Calculator

  '@x + @y = @result': (x, y, result) -> 
    @calculator.Add(x, y).should.eql result

  '@x - @y = @result': (x, y, result) -> 
    @calculator.Subtract(x, y).should.eql result

C# class

namespace Math
{
    public class Calculator
    {
        public int Add(int x, int y)
        {
            return x + y;
        }

        public int Subtract(int x, int y)
        {
            return x - y;
        }
    }
}
Clone this wiki locally