public void Ayende_View_On_Mocking()
		{
			ISomeSystem mockSomeSystem = MockRepository.GenerateStrictMock<ISomeSystem>();

            mockSomeSystem.Expect(x => x.GetFooFor<ExpectedBar>("foo"))
                .Return(new List<ExpectedBar>());

            ExpectedBarPerformer cut = new ExpectedBarPerformer(mockSomeSystem);

            Assert.Throws<ExpectationViolationException>(
                @"ISomeSystem.GetFooFor<Rhino.Mocks.Tests.FieldsProblem.UnexpectedBar>(""foo""); Expected #1, Actual #1.
ISomeSystem.GetFooFor<Rhino.Mocks.Tests.FieldsProblem.ExpectedBar>(""foo""); Expected #1, Actual #0.",
                () => cut.DoStuffWithExpectedBar("foo"));
		}
Beispiel #2
0
        public void Ayende_View_On_Mocking()
        {
            ISomeSystem mockSomeSystem = MockRepository.GenerateStrictMock <ISomeSystem>();

            mockSomeSystem.Expect(x => x.GetFooFor <ExpectedBar>("foo"))
            .Return(new List <ExpectedBar>());

            ExpectedBarPerformer cut = new ExpectedBarPerformer(mockSomeSystem);

            Assert.Throws <ExpectationViolationException>(
                @"ISomeSystem.GetFooFor<Rhino.Mocks.Tests.FieldsProblem.UnexpectedBar>(""foo""); Expected #1, Actual #1.
ISomeSystem.GetFooFor<Rhino.Mocks.Tests.FieldsProblem.ExpectedBar>(""foo""); Expected #1, Actual #0.",
                () => cut.DoStuffWithExpectedBar("foo"));
        }
        public void Ayende_View_On_Mocking()
        {
            MockRepository mocks = new MockRepository();
            ISomeSystem mockSomeSystem = mocks.StrictMock<ISomeSystem>();

            using (mocks.Record())
            {
                Expect.Call(mockSomeSystem.GetFooFor<ExpectedBar>("foo"))
                    .Return(new List<ExpectedBar>());
            }

            using (mocks.Playback())
            {
                ExpectedBarPerformer cut = new ExpectedBarPerformer(mockSomeSystem);
                cut.DoStuffWithExpectedBar("foo");
            }
        }
        public void Ayende_View_On_Mocking()
        {
            MockRepository mocks = new MockRepository();
            ISomeSystem mockSomeSystem = mocks.StrictMock<ISomeSystem>();

            using (mocks.Record())
            {
                Expect.Call(mockSomeSystem.GetFooFor<ExpectedBar>("foo"))
                    .Return(new List<ExpectedBar>());
            }

            var ex = Assert.Throws<ExpectationViolationException>(() =>
                                                                  	{
                                                                  		using (mocks.Playback())
                                                                  		{
                                                                  			ExpectedBarPerformer cut = new ExpectedBarPerformer(mockSomeSystem);
                                                                  			cut.DoStuffWithExpectedBar("foo");
                                                                  		}
                                                                  	});
            Assert.Equal(@"ISomeSystem.GetFooFor<Rhino.Mocks.Tests.FieldsProblem.UnexpectedBar>(""foo""); Expected #1, Actual #1.
            ISomeSystem.GetFooFor<Rhino.Mocks.Tests.FieldsProblem.ExpectedBar>(""foo""); Expected #1, Actual #0.", ex.Message);
        }
        public void Ayende_View_On_Mocking()
        {
            MockRepository mocks          = new MockRepository();
            ISomeSystem    mockSomeSystem = mocks.StrictMock <ISomeSystem>();

            using (mocks.Record())
            {
                Expect.Call(mockSomeSystem.GetFooFor <ExpectedBar>("foo"))
                .Return(new List <ExpectedBar>());
            }

            Assert.Throws <ExpectationViolationException>(
                @"ISomeSystem.GetFooFor<Rhino.Mocks.Tests.FieldsProblem.UnexpectedBar>(""foo""); Expected #1, Actual #1.
ISomeSystem.GetFooFor<Rhino.Mocks.Tests.FieldsProblem.ExpectedBar>(""foo""); Expected #1, Actual #0.",
                () =>
            {
                using (mocks.Playback())
                {
                    ExpectedBarPerformer cut = new ExpectedBarPerformer(mockSomeSystem);
                    cut.DoStuffWithExpectedBar("foo");
                }
            }
                );
        }