private void SetupGiven(ref Mockery mocks, ref SimplestPossibleWorld world)
 {
     IGiven given = (IGiven)mocks.NewMock<IGiven>();
     Expect.AtLeast(1).On(given).Method("Setup").With(world);
     List<IGiven> GivenCollection = new List<IGiven>();
     GivenCollection.Add(given);
 }
        private IScenario PrepareScenario()
        {
            Mockery mocks = new Mockery();
            SimplestPossibleWorld world = new SimplestPossibleWorld();

            SetupGiven(ref mocks, ref world);
            SetupEvent(ref mocks, ref world);
            SetupWorldOutcome(ref mocks, ref world);
            IScenario scenario = SetupScenario(ref mocks, ref world);

            return scenario;
        }
        private IScenario SetupScenario(ref Mockery mocks, ref SimplestPossibleWorld world)
        {
            IScenario scenario = mocks.NewMock<IScenario>();
            Expect.AtLeast(1).On(scenario).Method("SetupWorld").Will(Return.Value(world));
            Expect.AtLeast(0).On(scenario).SetProperty("World").To(world);
            Expect.AtLeast(0).On(scenario).GetProperty("World").Will(Return.Value(world));
            Expect.AtLeast(1).On(scenario).Method("Specify");

            Outcome o = CreateSuccessfulOutcome();
            Expect.AtLeast(1).On(scenario).Method("Run").Will(Return.Value(o));

            return scenario;
        }
        public void ShouldRunStorySuccessfully()
        {
            //Given
            Mockery mocks = new Mockery();
            SimplestPossibleWorld world = new SimplestPossibleWorld();
            IStory story = new FakeStory();

            //Story has scenarios
            IScenario scenario = mocks.NewMock<IScenario>();

            story.AddScenario(scenario);

            Expect.Once.On(scenario).Method("Run").Will(Return.Value(new Outcome(OutcomeResult.Passed, "yadda yadda")));

            //When
            story.Run();

            //Then
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
        public void ShouldRaiseWorldEvent()
        {
            //Given
            Mockery mocks = new Mockery();
            SimplestPossibleWorld world = new SimplestPossibleWorld();
            IEvent evt = mocks.NewMock<IEvent>();
            Expect.Once.On(evt).Method("OccurIn").With(world);

            Scenario.Scenario scenario = new MyScenario(null, evt, null, world);
            //When
            scenario.WorldEvent();

            //Then
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
 //public MyScenario(IList<IGiven> givens, IEvent evt, IOutcomeCollection<SimplestPossibleWorld> outcomes) : base(givens, evt, outcomes) { }
 public MyScenario(IList<IGiven> givens, IEvent evt, IList<IWorldOutcome> outcomes, SimplestPossibleWorld world)
     : base(givens, evt, outcomes, world)
 {
 }
        public void ShouldVerifyOutcome()
        {
            //Given
            Mockery mocks = new Mockery();
            SimplestPossibleWorld world = new SimplestPossibleWorld();

            IWorldOutcome outcome = mocks.NewMock<IWorldOutcome>();
            Expect.Once.On(outcome).Method("Verify").With(world);

            Outcome outcomeResult = new Outcome(OutcomeResult.Passed, "Cool");
            Expect.Once.On(outcome).GetProperty("Result").Will(Return.Value(outcomeResult));

            List<IWorldOutcome> lst = new List<IWorldOutcome>();
            lst.Add(outcome);
            Scenario.Scenario scenario = new MyScenario(null, null, lst, world);
            //When
            scenario.VerifyOutcomes();

            //Then
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
        public void ShouldSetupGivens()
        {
            //Given
            Mockery mocks = new Mockery();

            SimplestPossibleWorld world = new SimplestPossibleWorld();

            IGiven aGiven = mocks.NewMock<IGiven>();
            Expect.Once.On(aGiven).Method("Setup").With(world);

            List<IGiven> l = new List<IGiven>();
            l.Add(aGiven);
            Scenario.Scenario scenario = new MyScenario(l, null, null, world);
            //When
            scenario.SetupGivens();

            //Then
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
        public void ShouldRunScenario()
        {
            //Given
            Mockery mocks = new Mockery();
            SimplestPossibleWorld world = new SimplestPossibleWorld();

            IGiven given = (IGiven)mocks.NewMock<IGiven>();
            Expect.Once.On(given).Method("Setup").With(world);
            List<IGiven> GivenCollection = new List<IGiven>();
            GivenCollection.Add(given);

            IEvent evt = mocks.NewMock<IEvent>();
            Expect.Once.On(evt).Method("OccurIn").With(world);

            IWorldOutcome outcome = mocks.NewMock<IWorldOutcome>();
            Expect.Once.On(outcome).Method("Verify").With(world);
            Expect.Once.On(outcome).GetProperty("Result").Will(Return.Value(new Outcome(OutcomeResult.Passed, "Cool")));
            List<IWorldOutcome> outcomeCollection = new List<IWorldOutcome>();
            outcomeCollection.Add(outcome);

            IScenario scenario = new MyScenario(GivenCollection, evt, outcomeCollection, world);

            //When
            scenario.Run();

            //Then
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
 private void SetupWorldOutcome(ref Mockery mocks, ref SimplestPossibleWorld world)
 {
     IWorldOutcome outcome = mocks.NewMock<IWorldOutcome>();
     Expect.AtLeast(1).On(outcome).Method("Verify").With(world);
     Expect.AtLeast(1).On(outcome).GetProperty("Result").Will(Return.Value(CreateSuccessfulOutcome()));
     List<IWorldOutcome> outcomeCollection = new List<IWorldOutcome>();
     outcomeCollection.Add(outcome);
 }
 private void SetupEvent(ref Mockery mocks, ref SimplestPossibleWorld world)
 {
     IEvent evt = mocks.NewMock<IEvent>();
     Expect.AtLeast(1).On(evt).Method("OccurIn").With(world);
 }