1. Johannes Rudolph
  2. SubSpec

Commits

Johannes Rudolph  committed 227ee31

Updated to reflect recommended syntax

  • Participants
  • Parent commits 99e5327
  • Branches default

Comments (0)

Files changed (1)

File Home.wiki

View file
  • Ignore whitespace
 {{{
 #!csharp
 
-	[Specification]
-	public void PushSpecification()
-	{
-		var sut = default(Stack<int>);
-		"Given a new stack"
-			.Context(
-			     () => sut = new Stack<int>());
+        [Specification]
+        public void PushSpecification()
+        {
+            var sut = default( Stack<int> );
+            "Given a new stack"
+                .Context( () =>
+                    sut = new Stack<int>() );
 
-		"with an element pushed onto it"
-			.Do(
-			     () => sut.Push(11));
+            "with an element pushed onto it"
+                .Do( () => 
+                    sut.Push( 11 ) );
 
-		"expect the stack is not empty"
-			.Assert(
-			     () => Assert.False(sut.IsEmpty));
-		
-		"expect the stacks Top is the pushed element"
-			.Assert(
-			     () => Assert.Equals(11, sut.Top));
-	}
+            "expect the stack is not empty"
+                .Assert( () =>
+                    Assert.False( sut.Count == 0 ) );
+
+            "expect the stacks Top is the pushed element"
+                .Assert( () =>
+                {
+                    var top = sut.Peek();
+                    Assert.Equals( 11, top );
+                } );   
+        }
 }}}
 
 In order to support a **fluent syntax**, SubSpec allows you to specify each of the primitives as extension methods on strings that describe the primitive action that you pass as an argument to the Context (Arrange), Do (Act), or Assert (well, Assert) method.