public
Description: Given When Then (GWT) extension for xUnit.net
Homepage:
Clone URL: git://github.com/BenHall/xUnit.GWT.git
xUnit.GWT / xUnit.GWT / Example / This_is_my_story.cs
100644 78 lines (70 sloc) 2.772 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
namespace xUnit.GWT.Example
{
    //[As_A("User...")]
    //[I_Want("To...")]
    //[So_That("I...")]
[Feature("As a user... I want to... So that I...")]
    public class This_is_my_story : This_is_my_story_Base
    {
[Scenario]
        public void when_transferring_between_two_accounts()
        {
            Given("both accounts have positive balances");
            When("transfer money from a to b");
            Then("a should have the total balance of b", () => a.Balance.ShouldBe(3));
            Then("balance of b should be 0", () => b.Balance.ShouldBe(0));
        }
 
[Scenario]
        public void if_then_is_wrong_then_it_should_fail()
        {
            Given("both accounts have positive balances");
            When("transfer money from a to b");
            Then("a should have the total balance of b", () => a.Balance.ShouldBe(3));
            Then("balance of b should be 0", () => b.Balance.ShouldBe(3));
        }
 
[Scenario]
        public void part_is_missing()
        {
            Given("one valid given block", Pending);
            When("there is no then block [then it should fail]", Pending);
            //Then("it should fail");
        }
 
[Scenario]
        public void test_marked_as_pending()
        {
            Given("one pending block", Pending);
            Then("it should be marked as pending in the report");
        }
 
[Scenario]
        public void pending_block()
        {
            Given("a block which has been defined");
            When("no action assigned", Pending);
            Then("it should be marked as pending");
        }
    }
 
    public class This_is_my_story_Base : Story
    {
        protected Account a;
        protected Account b;
 
        public This_is_my_story_Base()
        {
            SetGiven("both accounts have positive balances", () =>
                                                                 {
                                                                     a = new Account();
                                                                     a.Balance = 1;
                                                                     b = new Account();
                                                                     b.Balance = 2;
                                                                 });
 
            SetWhen("transfer money from a to b", () =>
                                                      {
                                                          a.Balance += b.Balance;
                                                          b.Balance = 0;
                                                      });
        }
    }
 
    public class Account
    {
        public int Balance;
    }
}