Created
December 28, 2011 17:44
-
-
Save tkellogg/1528845 to your computer and use it in GitHub Desktop.
BDD in C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
class when_adding_numbers | |
{ | |
Maths maths; | |
void Given_an_object_in_bigint_mode() | |
{ | |
maths = new Maths(); | |
maths.BigInt = true; | |
} | |
[Test] | |
public void it_doesnt_overflow_the_size_of_an_int() | |
{ | |
Given_an_object_in_bigint_mode(); | |
Assert.That(maths.Add(int.MAX, 1), Is.GreaterThan(int.Max)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var spec = new Spec(describe: typeof(Maths)); | |
spec.It["doesn't overflow the size of an int"] = maths.Add(int.MAX, 1).Should() > int.MAX |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maths.Add(int.MAX, 1).Should() > int.MAX; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "Maths#add" do | |
before :each do | |
@math = Maths.new | |
end | |
context "when in bigint mode" do | |
before :each do | |
@math.bigint = true | |
end | |
it "doesn't overflow the size of an int" do | |
@math.add(int.MAX, 1).should > int.MAX | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maths.Add(int.MAX, 1).Should().BeGreaterThan(int.MAX); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "Maths#add" do | |
before :each do | |
@math = Maths.new | |
end | |
it "should add two numbers" do | |
@math.add(5, 6).should == 11 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment