and it was also different than what was included in the original email. Which would have worked as it used o=> rather than a name that was almost the same as an existing variable.
Normally copy and paste coding should be avoided, but in this case it might have been a better idea ;) On 2 September 2010 12:55, Tim Barcz <[email protected]> wrote: > You said in your original email that it worked on every PC but the one - > were you not running the same code? > > On Sep 2, 2010, at 4:35 AM, Mark Whitfeld <[email protected]> wrote: > > > I have found the problem!!!!! > > It is so simple, but so easy to miss! > > If you had have run the tests I posted, it would also have failed for > > you. > > So, it is nothing to do with it not working on my machine, but it is > > all about the actual code being tested! Curious...? > > Well Have a look at these two tests: > > > > [TestFixture] > > public class TestMocking > > { > > [Test] > > public void Test_ThisWorks() > > { > > IBob bob = MockRepository.GenerateStub<IBob>(); > > bob.AssertWasNotCalled(bob1 => bob1.Action()); > > } > > > > [Test] > > public void Test_ThisDoesntWork() > > { > > IBob bob = MockRepository.GenerateStub<IBob>(); > > bob.AssertWasNotCalled(bob1 => bob.Action()); > > } > > } > > > > public interface IBob > > { > > void Action(); > > } > > > > The one works, but the other doesn't... Do you spot the difference? > > :)... Dramatic pause... > > The second test refers to the outside variable in the lambda instead > > of the parameter! > > That's it. That is why it is failing! So simple, but so easy to miss. > > The reason why it worked on other PCs is because I just typed out the > > tests again there instead of copy pasting the code (I was being lazy, > > ok). > > > > But this does bring me to that error message: > > "No expectations were setup to be verified, ensure that the method > > call in the action is a virtual (C#) / overridable (VB.Net) method > > call" > > > > It really throws you doesn't it! Well, for me it does. > > Would it not be a good thing to add a check on the lambda expression > > to see if it calls a method on the actual parameter passed in anywhere > > in the lambda. > > Or does it not use lambda expressions for this... > > > > Anyway. Problem solved. I don't need to reformat my PC anymore (maybe > > just my mind...). > > Shot for your efforts. > > -Mark > > > > On Aug 27, 2:49 pm, Tim Barcz <[email protected]> wrote: > >> Ah ok ok... So you were in VS 2010? I can run then on my machine as well > >> > >> On Aug 27, 2010, at 7:38 AM, Mark Whitfeld <[email protected]> > wrote: > >> > >>> Ok, I checked out the rhino mocks code and ran all the tests. > >>> The tests all pass and if I add my test above, it also passes! > >> > >>> It seems that it is not working in new VS2010 projects. > >>> I will investigate further when I get a chance... > >> > >>> On Aug 27, 9:11 am, Mark Whitfeld <[email protected]> wrote: > >>>> Yeah, my previous machine was Win 7 64-bit as well and it worked. > >>>> It only doesn't run on this machine... Arrgh! > >> > >>>> What do you mean by TDD.net? Never heard of it. Unless you mean > >>>> TestDriven.net, but I don't use that because I have resharper. > >> > >>>> I don't hink that this is an issue with the test runner because it > >>>> gives the same result no matter what test runner I use. > >>>> The issue is possibly in how Rhino Mocks is determining whether it can > >>>> mock the interface. > >>>> But something is breaking on my machine only. Do you think it could be > >>>> a permissions issue. I am an administrator on this machine though. > >> > >>>> I think I will download the Rhino Mocks Source code and try to run > >>>> it's tests. Possibly even debug this from the source code. > >> > >>>> On Aug 26, 4:55 pm, Tim Barcz <[email protected]> wrote: > >> > >>>>> Oddly I have a Win 7 64-bit system and everything works fine..... > >> > >>>>> What version of TDD.NET? > >> > >>>>> On Thu, Aug 26, 2010 at 2:31 AM, Mark Whitfeld < > [email protected]>wrote: > >> > >>>>>> Hi Tim > >> > >>>>>> I am using NUnit 2.5.6, I have also tried 2.5.3 as well as the > >>>>>> Resharper Test runner. > >>>>>> It doesn't work in any of these... Only on my machine... :( > >> > >>>>>> Thanks > >>>>>> -Mark > >> > >>>>>> On Aug 25, 3:43 pm, Tim Barcz <[email protected]> wrote: > >>>>>>> Mark, > >> > >>>>>>> Please tell me what version of NUnit are you running? > >> > >>>>>>> Tim > >> > >>>>>>> On Wed, Aug 25, 2010 at 2:06 AM, Mark Whitfeld < > [email protected] > >>>>>>> wrote: > >> > >>>>>>>> Oh, before I forget to mention. I am using Rhino.Mocks 3.6 > >> > >>>>>>>> Thanks for your reply. > >>>>>>>> Yeah, I tried that as well. It doesn't work either... > >>>>>>>> I get: > >> > >>>>>>>> System.InvalidOperationException : No expectations were setup to > be > >>>>>>>> verified, ensure that the method call in the action is a virtual > >>>>>>>> (C#) / overridable (VB.Net) method call > >>>>>>>> at > >> > >>>>>> > Rhino.Mocks.RhinoMocksExtensions.AssertExactlySingleExpectaton(MockRepository > >>>>>>>> mocks, T mockToRecordExpectation) > >>>>>>>> at Rhino.Mocks.RhinoMocksExtensions.GetExpectationsToVerify(T > mock, > >>>>>>>> Action`1 action, Action`1 setupConstraints) > >>>>>>>> at Rhino.Mocks.RhinoMocksExtensions.AssertWasNotCalled(T mock, > >>>>>>>> Action`1 action, Action`1 setupConstraints) > >>>>>>>> at Rhino.Mocks.RhinoMocksExtensions.AssertWasNotCalled(T mock, > >>>>>>>> Action`1 action) > >>>>>>>> at Habanero.Templates.Test.Processor.TestMocking.Test_ShouldWork > >> > >>>>>>>> It fails in the same place. Could it be an issue with Castle do > you > >>>>>>>> think? > >>>>>>>> I hope I don't have to use a different mocking framework just > because > >>>>>>>> it doesn't work on my machine! > >> > >>>>>>>> On Aug 24, 3:43 pm, Tuna Toksoz <[email protected]> wrote: > >>>>>>>>> [TestFixture] > >>>>>>>>> public class TestMocking > >>>>>>>>> { > >>>>>>>>> [Test] > >>>>>>>>> public void Test_AssertWasNotCalled_ShouldWork() > >>>>>>>>> { > >>>>>>>>> var bob = MockRepository.GenerateMock<IBob>(); > >>>>>>>>> bob.AssertWasNotCalled(o => o.Action()); > >>>>>>>>> } > >> > >>>>>>>>> } > >> > >>>>>>>>> Can you try that? > >> > >>>>>>>>> Tuna Toksöz > >>>>>>>>> Eternal sunshine of the open source mind. > >> > >>>>>>>> > http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitt. > >>>>>> .. > >> > >>>>>>>>> On Tue, Aug 24, 2010 at 3:30 AM, Mark Whitfeld < > >>>>>> [email protected] > >>>>>>>>> wrote: > >> > >>>>>>>>>> OK, I'm so stumped about this one! > >>>>>>>>>> I have been using Rhino Mocks for years and it has never given > me > >>>>>>>>>> problems. > >>>>>>>>>> I run the following simple code and it gives this error message: > >> > >>>>>>>>>> (on the line with AssertWasNotCalled) > >>>>>>>>>> System.InvalidOperationException : No expectations were setup to > be > >>>>>>>>>> verified, ensure that the method call in the action is a virtual > >>>>>>>>>> (C#) / overridable (VB.Net) method call > >> > >>>>>>>>>> Stack Trace: > >>>>>>>>>> at > >>>>>> Rhino.Mocks.RhinoMocksExtensions.AssertExactlySingleExpectaton[T] > >>>>>>>>>> (MockRepository mocks, T mockToRecordExpectation) > >>>>>>>>>> at Rhino.Mocks.RhinoMocksExtensions.GetExpectationsToVerify[T](T > >>>>>> mock, > >>>>>>>>>> Action`1 action, Action`1 setupConstraints) > >>>>>>>>>> at Rhino.Mocks.RhinoMocksExtensions.AssertWasNotCalled[T](T > mock, > >>>>>>>>>> Action`1 action, Action`1 setupConstraints) > >>>>>>>>>> at Rhino.Mocks.RhinoMocksExtensions.AssertWasNotCalled[T](T > mock, > >>>>>>>>>> Action`1 action) > >>>>>>>>>> at > Habanero.Templates.Test.Processor.TestMocking.Test_ShouldWork() > >> > >>>>>>>>>> Here is the code (I know its testing the mocking framework, > that's > >>>>>> the > >>>>>>>>>> point): > >> > >>>>>>>>>> [TestFixture] > >>>>>>>>>> public class TestMocking > >>>>>>>>>> { > >>>>>>>>>> [Test] > >>>>>>>>>> public void Test_AssertWasNotCalled_ShouldWork() > >>>>>>>>>> { > >>>>>>>>>> var bob = MockRepository.GenerateStub<IBob>(); > >>>>>>>>>> bob.AssertWasNotCalled(o => o.Action()); > >>>>>>>>>> } > >>>>>>>>>> } > >> > >>>>>>>>>> public interface IBob > >>>>>>>>>> { > >>>>>>>>>> void Action(); > >>>>>>>>>> } > >> > >>>>>>>>>> The project is compiled for AnyCPU (and I have tried all the > >>>>>> others) > >>>>>>>>>> and .NET 3.5. > >>>>>>>>>> This fails on my PC, but works on every other PC. Aaaargh! > >> > >>>>>>>>>> My PC is as follows: > >>>>>>>>>> Intel Core i7 CPU 860 @ 2.80GHz > >>>>>>>>>> 8.00 GB RAM > >>>>>>>>>> Windows 7 64-bit OS > >> > >>>>>>>>>> I have restarted Visual Studio, and the PC as well as run the > tests > >>>>>>>>>> from Resharper and the nunit test runner. > >>>>>>>>>> All have the same result: It fails! > >> > >>>>>>>>>> Please help! > >> > >>>>>>>>>> -- > >>>>>>>>>> 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]<rhinomocks%[email protected]> > <rhinomocks%[email protected]<rhinomocks%[email protected]> > > > >>>>>> <rhinomocks%[email protected]<rhinomocks%[email protected]> > <rhinomocks%[email protected]<rhinomocks%[email protected]> > > > >> > >>>>>>>> <rhinomocks%[email protected]<rhinomocks%[email protected]> > <rhinomocks%[email protected]<rhinomocks%[email protected]> > > > >>>>>> <rhinomocks%[email protected]<rhinomocks%[email protected]> > <rhinomocks%[email protected]<rhinomocks%[email protected]> > > > >> > >>>>>>>>>> . > >>>>>>>>>> For more options, visit this group at > >>>>>>>>>> http://groups.google.com/group/rhinomocks?hl=en. > >> > >>>>>>>> -- > >>>>>>>> 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]<rhinomocks%[email protected]> > <rhinomocks%[email protected]<rhinomocks%[email protected]> > > > >>>>>> <rhinomocks%[email protected]<rhinomocks%[email protected]> > <rhinomocks%[email protected]<rhinomocks%[email protected]> > > > >> > >>>>>>>> . > >>>>>>>> For more options, visit this group at > >>>>>>>> http://groups.google.com/group/rhinomocks?hl=en. > >> > >>>>>>> -- > >>>>>>> Tim Barcz > >>>>>>> Microsoft C# MVP > >>>>>>> Microsoft ASPInsiderhttp://timbarcz.devlicio.ushttp:// > >>>>>> www.twitter.com/timbarcz > >> > >>>>>> -- > >>>>>> 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]<rhinomocks%[email protected]> > <rhinomocks%[email protected]<rhinomocks%[email protected]> > > > >>>>>> . > >>>>>> For more options, visit this group at > >>>>>> http://groups.google.com/group/rhinomocks?hl=en. > >> > >>>>> -- > >>>>> Tim Barcz > >>>>> Microsoft C# MVP > >>>>> Microsoft ASPInsiderhttp://timbarcz.devlicio.ushttp:// > www.twitter.com/timbarcz > >> > >>> -- > >>> 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]<rhinomocks%[email protected]> > . > >>> For more options, visit this group athttp:// > groups.google.com/group/rhinomocks?hl=en. > >> > >> > > > > -- > > 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]<rhinomocks%[email protected]> > . > > For more options, visit this group at > http://groups.google.com/group/rhinomocks?hl=en. > > > > -- > 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]<rhinomocks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rhinomocks?hl=en. > > -- 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.
