package com.dc.test.context;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import org.junit.Rule;
import org.junit.Test;

import com.dc.test.context.junit.ContextRule;

public class ContextRuleTest {

    @Rule
    public ContextRule context = new ContextRule(this);

    Object a;
    Object b;

    @BeforeContext("a is not null")
    public void aIsNotNullSetUp() {
        a = new Object();
    }

    @BeforeContext("b is not null")
    public void bIsNotNullSetUp() {
        b = new Object();
    }

    @Test
    @Context(when = "a is not null")
    public void shouldOnlyExecuteAIsNotNullBeforeTheTest() {

        assertNotNull(a);
        assertNull(b);
    }

    @Test
    @Context(when = "b is not null")
    public void shouldOnlyExecuteBIsNotNullBeforeTheTest() {

        assertNotNull(b);
        assertNull(a);
    }

    @Test
    @Context(whenEachOf = { "a is not null", "b is not null" })
    public void shouldExecuteTheBeforeContextsForBothAAndB() {

        assertNotNull(a);
        assertNotNull(b);
    }
}

@@ -317,17 +317,19 @@
  Object 
-a
+foo
 ;%0A    Ob
@@ -334,16 +334,18 @@
 Object b
+ar
 ;%0A%0A    @
@@ -359,17 +359,19 @@
 ontext(%22
-a
+foo
  is not 
@@ -393,17 +393,19 @@
 ic void 
-a
+foo
 IsNotNul
@@ -423,17 +423,19 @@
         
-a
+foo
  = new O
@@ -471,16 +471,18 @@
 ntext(%22b
+ar
  is not 
@@ -505,16 +505,18 @@
 c void b
+ar
 IsNotNul
@@ -535,16 +535,18 @@
        b
+ar
  = new O
@@ -592,17 +592,19 @@
 when = %22
-a
+foo
  is not 
@@ -643,17 +643,19 @@
 yExecute
-A
+Foo
 IsNotNul
@@ -688,33 +688,35 @@
   assertNotNull(
-a
+foo
 );%0A        asser
@@ -718,24 +718,26 @@
 assertNull(b
+ar
 );%0A    %7D%0A%0A  
@@ -766,16 +766,18 @@
 hen = %22b
+ar
  is not 
@@ -817,16 +817,18 @@
 ExecuteB
+ar
 IsNotNul
@@ -866,24 +866,26 @@
 ertNotNull(b
+ar
 );%0A        a
@@ -890,25 +890,27 @@
  assertNull(
-a
+foo
 );%0A    %7D%0A%0A  
@@ -946,17 +946,19 @@
 Of = %7B %22
-a
+foo
  is not 
@@ -966,16 +966,18 @@
 ull%22, %22b
+ar
  is not 
@@ -1042,13 +1042,17 @@
 Both
-A
+Foo
 AndB
+ar
 () %7B
@@ -1075,17 +1075,19 @@
 NotNull(
-a
+foo
 );%0A     
@@ -1104,16 +1104,18 @@
 otNull(b
+ar
 );%0A    %7D

Update naming