Exemplo n.º 1
0
        public List <PizzaPie> OrderPizza(string name, int quantity)
        {
            var count = 1;
            var pies  = new List <PizzaPie>();

            while (count <= quantity)
            {
                pies.Add(PizzaMaker.MakePizza(name));
                count += 1;
            }

            return(pies);
        }
Exemplo n.º 2
0
        public void WhenMakePizzaEndsThenPizzaMakerIsReadyForAnotherPizza()
        {
            // ARRANGE
            var stubIngredientsProvider = MockRepository.GenerateStub <IIngredientsProvider>();
            var stubRawPizzaBUilder     = MockRepository.GenerateStub <IRawPizzaBuilder>();
            var stubOven = MockRepository.GenerateStub <IOven>();

            // ACT
            var sut   = new PizzaMaker(stubIngredientsProvider, stubRawPizzaBUilder, stubOven);
            var pizza = sut.MakePizza();

            // ASSERT
            Assert.IsTrue(sut.ReadyForMakePizza);
        }
Exemplo n.º 3
0
        public void WeNeverForgetToCookPizzaInTheOven()
        {
            // ARRANGE
            var stubIngredientsProvider = MockRepository.GenerateStub <IIngredientsProvider>();
            var stubRawPizzaBUilder     = MockRepository.GenerateStub <IRawPizzaBuilder>();
            var mockOven = MockRepository.GenerateStub <IOven>();

            mockOven.Stub(oven => oven.CookPizza(Arg <IRawPizza> .Is.Anything));

            // ACT
            var sut   = new PizzaMaker(stubIngredientsProvider, stubRawPizzaBUilder, mockOven);
            var pizza = sut.MakePizza();

            // ASSERT
            mockOven.AssertWasCalled(oven => oven.CookPizza(Arg <IRawPizza> .Is.Anything));
        }
Exemplo n.º 4
0
        public void WhyTheStrictMockIsGenerallyBad()
        {
            //ARRANGE
            var stubIngredientsProvider = MockRepository.GenerateStub <IIngredientsProvider>();
            var stubRawPizzaBuilder     = MockRepository.GenerateStub <IRawPizzaBuilder>();

            var mockOven = MockRepository.GenerateStrictMock <IOven>(); //DISCOURAGED

            mockOven.Expect(oven => oven.Temperature = 300);
            mockOven.Expect(oven => oven.Temperature = 150);
            mockOven.Expect(oven => oven.CookPizza(Arg <IRawPizza> .Is.Anything));

            // ACT
            var sut = new PizzaMaker(stubIngredientsProvider, stubRawPizzaBuilder, mockOven);

            sut.MakePizza();

            // ASSERT
            mockOven.VerifyAllExpectations();
        }
Exemplo n.º 5
0
        public void PizzaMakerSetOvenToTheProperTemperature()
        {
            // ARRANGE
            IIngredientsProvider stubIngredientsProvider = MockRepository.GenerateStub <IIngredientsProvider>();
            IRawPizzaBuilder     stubRawPizzaBUilder     = MockRepository.GenerateStub <IRawPizzaBuilder>();

            // this won't work. We can't verify this call. If you comment out the property settings in the method under test, this test won't fail
            //IOven mockOven = MockRepository.GenerateStub<IOven>();
            //mockOven.Temperature = 300;
            //mockOven.Temperature = 150;

            //this is the proper way to check settings on property
            IOven mockOven = MockRepository.GenerateMock <IOven>();

            mockOven.Expect(oven => oven.Temperature = 300);
            mockOven.Expect(oven => oven.Temperature = 150);

            // ACT
            var sut   = new PizzaMaker(stubIngredientsProvider, stubRawPizzaBUilder, mockOven);
            var pizza = sut.MakePizza();

            // ASSERT
            mockOven.VerifyAllExpectations();
        }
Exemplo n.º 6
0
 public void ProjectReference()
 {
     var p = PizzaMaker.MakePizza("Pineapple");
 }