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); }
public void ShouldAddOutcome() { //Given Mockery mocks = new Mockery(); IGiven aGiven = (IGiven)mocks.NewMock <IGiven>(); IEvent evt = mocks.NewMock <IEvent>(); IWorldOutcome outcome = mocks.NewMock <IWorldOutcome>(); List <IGiven> givenCollection = new List <IGiven>(); List <IWorldOutcome> outcomeCollection = new List <IWorldOutcome>(); IScenario scenario = new MyScenario(givenCollection, null, outcomeCollection, null); //When scenario.Given("a given", aGiven).When("an event", evt).Then("an outcome", outcome); //Then Assert.AreEqual(1, outcomeCollection.Count); }
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(); }