Hmmmm.....Did I smoke a wrong weed this morning? :-) It definitely does not work for me (the test passes). Let me try 3.6 - maybe it was an issue in 3.5 and has been fixed.
Alex, thank you for your efforts. BTW, I get more and more annoyed with VB. I don't like C# syntax either, but still it looks simpler than VB. On Oct 30, 10:59 am, Alex McMahon <[email protected]> wrote: > Yes the test fails on my machine. > > If I comment out one of the testMock.TestFunc() then it passes. Works > with both GenerateStub<> GenerateMock<> and GenerateStrictMock<> as > long as I add: > > mock.Stub(x=>x.TestFunc()).Return(null); > > early on. > > I'm using Rhino Mocks 3.6 btw > > 2009/10/30 Tarpan <[email protected]>: > > > > > Does the test _fail_ on your machine? > > > On Oct 30, 10:39 am, Alex McMahon <[email protected]> wrote: > >> Works on my machine... I changed it to C# and the following works > >> (test fails). So maybe it's about it being in VB? > > >> public interface ITestMock > >> { > >> object TestFunc(); > >> } > > >> public class TestClass > >> { > >> ITestMock testMock; > > >> public TestClass(ITestMock testMock) > >> { > >> this.testMock = testMock; > >> } > > >> public void test() > >> { > >> testMock.TestFunc(); > >> testMock.TestFunc(); > >> } > >> } > > >> [TestClass] > >> public class UnitTest1 > >> { > >> [TestMethod] > >> public void TestMethod1() > >> { > >> var mock = MockRepository.GenerateMock<ITestMock>(); > >> var target = new TestClass(mock); > >> target.test(); > >> mock.AssertWasCalled(x => x.TestFunc(), o => o.Repeat.Once()); > >> } > >> } > > >> 2009/10/30 Tarpan <[email protected]>: > > >> > Guys, Here is a simple test: > >> > TestClass calls the TestMock twice and there is a > >> > Assert...Repeat.Once. The test runs just fine. > >> > I know I'm doing something wrong. But what? > > >> > ------------- > >> > Imports MbUnit.Framework > >> > Imports Rhino.Mocks > > >> > <TestFixture()> _ > >> > Public Class AAA_test > >> > <Test()> _ > >> > Public Sub Test1() > >> > Dim TestMock As ITestMock = MockRepository.GenerateStub(Of > >> > ITestMock)() > >> > Dim TestClass As CTestClass = New CTestClass > >> > TestClass.test(TestMock) > >> > TestMock.AssertWasCalled(Function(x) x.TestFunc, Function > >> > (options) options.Repeat.Once) > >> > End Sub > >> > End Class > > >> > Public Class CTestClass > >> > Public Sub test(ByVal TestMock As ITestMock) > >> > TestMock.TestFunc() > >> > TestMock.TestFunc() > >> > End Sub > >> > End Class > > >> > Public Interface ITestMock > >> > Function TestFunc() As Object > >> > End Interface > >> > ---------------- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en -~----------~----~----~----~------~----~------~--~---
