[RhinoMocks] Re: Set only properties
Excellent, thank you Phil. Colin On Jan 19, 3:52 pm, Phil wrote: > try: m_contactPresenter.ContactAdapter.AssertWasCalled(a => a.Names = > null); > > On Jan 19, 3:03 am, Colin Desmond > wrote: > > > In the fluent syntax is it possible to test whether a set only > > property (not get method defined) is called. I am not too bothered > > about the parameters being passed. > > > So far I have tried: > > > m_contactPresenter.ContactAdapter.AssertWasCalled(a => a.Names); > > > and > > > Expect.Call > > (m_contactPresenter.ContactAdapter.Names).SetPropertyAndIgnoreArgument > > (); > > > But I keep getting > > > The property or indexer 'CoreLibrary.Contact.IContactAdapter.Names' > > cannot be used in this context because it lacks the get accessor. > > > Thanks again, > > > Colin. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to RhinoMocks@googlegroups.com To unsubscribe from this group, send email to rhinomocks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/RhinoMocks?hl=en -~--~~~~--~~--~--~---
[RhinoMocks] issue with Rhino Mocks 3.5 for 2.0 download @ ayende's site
Hello, - When i download Rhino Mocks 3.5 for 2.0 (http://ayende.com/20/ section.aspx/download/228) i notice that there is a reference to System.Core (which is a .NET 3.5 assembly). This obviously is not desired... - When i tried to compile the source i noticed that the MethodInvocation class is not in the Rhino.Mocks project file, and thus results in a compilation error. - There is also an Xml comment missing (forgot in which class) Greetz, Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to RhinoMocks@googlegroups.com To unsubscribe from this group, send email to rhinomocks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/RhinoMocks?hl=en -~--~~~~--~~--~--~---
[RhinoMocks] Re: Set only properties
try: m_contactPresenter.ContactAdapter.AssertWasCalled(a => a.Names = null); On Jan 19, 3:03 am, Colin Desmond wrote: > In the fluent syntax is it possible to test whether a set only > property (not get method defined) is called. I am not too bothered > about the parameters being passed. > > So far I have tried: > > m_contactPresenter.ContactAdapter.AssertWasCalled(a => a.Names); > > and > > Expect.Call > (m_contactPresenter.ContactAdapter.Names).SetPropertyAndIgnoreArgument > (); > > But I keep getting > > The property or indexer 'CoreLibrary.Contact.IContactAdapter.Names' > cannot be used in this context because it lacks the get accessor. > > Thanks again, > > Colin. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to RhinoMocks@googlegroups.com To unsubscribe from this group, send email to rhinomocks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/RhinoMocks?hl=en -~--~~~~--~~--~--~---
[RhinoMocks] Re: System.TypeLoadException when using MockRepository
OK, I am happy with that as a solution. Colin. On Jan 19, 12:45 pm, Ayende Rahien wrote: > The issue is a problem with modopt in the CLR.Since it is the same thing > from your perspective, please use int > > On Mon, Jan 19, 2009 at 5:24 AM, Colin Desmond < > > colin.desm...@btopenworld.com> wrote: > > > OK, > > > If I change the C++/CLI syntax from > > > CoreLibrary::Common::IMSMContact^ LoadSMContact(long nId); > > > to > > > CoreLibrary::Common::IMSMContact^ LoadSMContact(int nId); > > > it all works, it doesn't like the long. This is interesting given that > > "int" and "long" both map to System.Int32! > > > Colin > > > On Jan 19, 9:32 am, Colin Desmond > > wrote: > > > We're using 3.5 SP1. > > > > When I rewrite the interface as C# it is happy. I'll try playing with > > > the C++/CLI syntax a little and see if I can get it to work. > > > > Colin > > > > On Jan 18, 9:15 pm, Ayende Rahien wrote: > > > > > what version of the runtime?if you write the same thing in C#, does it > > cause > > > > any issues? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to RhinoMocks@googlegroups.com To unsubscribe from this group, send email to rhinomocks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/RhinoMocks?hl=en -~--~~~~--~~--~--~---
[RhinoMocks] Re: System.TypeLoadException when using MockRepository
The issue is a problem with modopt in the CLR.Since it is the same thing from your perspective, please use int On Mon, Jan 19, 2009 at 5:24 AM, Colin Desmond < colin.desm...@btopenworld.com> wrote: > > OK, > > If I change the C++/CLI syntax from > > CoreLibrary::Common::IMSMContact^ LoadSMContact(long nId); > > to > > CoreLibrary::Common::IMSMContact^ LoadSMContact(int nId); > > it all works, it doesn't like the long. This is interesting given that > "int" and "long" both map to System.Int32! > > Colin > > On Jan 19, 9:32 am, Colin Desmond > wrote: > > We're using 3.5 SP1. > > > > When I rewrite the interface as C# it is happy. I'll try playing with > > the C++/CLI syntax a little and see if I can get it to work. > > > > Colin > > > > On Jan 18, 9:15 pm, Ayende Rahien wrote: > > > > > what version of the runtime?if you write the same thing in C#, does it > cause > > > any issues? > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to RhinoMocks@googlegroups.com To unsubscribe from this group, send email to rhinomocks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/RhinoMocks?hl=en -~--~~~~--~~--~--~---
[RhinoMocks] Set only properties
In the fluent syntax is it possible to test whether a set only property (not get method defined) is called. I am not too bothered about the parameters being passed. So far I have tried: m_contactPresenter.ContactAdapter.AssertWasCalled(a => a.Names); and Expect.Call (m_contactPresenter.ContactAdapter.Names).SetPropertyAndIgnoreArgument (); But I keep getting The property or indexer 'CoreLibrary.Contact.IContactAdapter.Names' cannot be used in this context because it lacks the get accessor. Thanks again, Colin. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to RhinoMocks@googlegroups.com To unsubscribe from this group, send email to rhinomocks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/RhinoMocks?hl=en -~--~~~~--~~--~--~---
[RhinoMocks] Re: System.TypeLoadException when using MockRepository
OK, If I change the C++/CLI syntax from CoreLibrary::Common::IMSMContact^ LoadSMContact(long nId); to CoreLibrary::Common::IMSMContact^ LoadSMContact(int nId); it all works, it doesn't like the long. This is interesting given that "int" and "long" both map to System.Int32! Colin On Jan 19, 9:32 am, Colin Desmond wrote: > We're using 3.5 SP1. > > When I rewrite the interface as C# it is happy. I'll try playing with > the C++/CLI syntax a little and see if I can get it to work. > > Colin > > On Jan 18, 9:15 pm, Ayende Rahien wrote: > > > what version of the runtime?if you write the same thing in C#, does it cause > > any issues? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to RhinoMocks@googlegroups.com To unsubscribe from this group, send email to rhinomocks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/RhinoMocks?hl=en -~--~~~~--~~--~--~---
[RhinoMocks] Re: System.TypeLoadException when using MockRepository
We're using 3.5 SP1. When I rewrite the interface as C# it is happy. I'll try playing with the C++/CLI syntax a little and see if I can get it to work. Colin On Jan 18, 9:15 pm, Ayende Rahien wrote: > what version of the runtime?if you write the same thing in C#, does it cause > any issues? > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to RhinoMocks@googlegroups.com To unsubscribe from this group, send email to rhinomocks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/RhinoMocks?hl=en -~--~~~~--~~--~--~---
[RhinoMocks] Re: Complete newbie's first try
I just wanted to test the interaction, not that the exact same list was being passed. With your suggestions, I came up with this: namespace CreateFlash.Tests { using NUnit.Framework; using Rhino.Mocks; using System.IO; using System.Collections.Generic; public interface IView { void RefreshList(IEnumerable disks); } public class Presenter { private IView view; public Presenter(IView view) { this.view = view; } public void Load() { this.view.RefreshList(new List() { new RemovableDisk("d", "c", 0) }); } } [TestFixture] public class TestPresenter { [Test] public void LoadShouldRefreshListAndCenterInScreen() { // arrange var stubView = MockRepository.GenerateStub(); // act var presenterUnderTest = new Presenter(stubView); presenterUnderTest.Load(); // assert stubView.AssertWasCalled(x => x.RefreshList(null), x => x.IgnoreArguments()); } } } This works for me! Thanks to Christiaan, Chris, and Neal! Regards, Daniel Lidström Stockholm, Sweden On Jan 18, 7:18 pm, Chris Missal wrote: > As Christiaan says, you need to pass in the same object for the mock > to assert it. I just ran into this problem myself. If you want to use > AssertWasCalled and ignore the arguments, you can use it in this > manner: > > stubView.AssertWasCalled(x => x.RefreshList(removableDisks), x => > x.IgnoreArguments()); > > On Jan 18, 10:44 am, Daniel Lidström wrote: > > > Hello, > > > I am trying Rhino.Mocks for the first time. As I am new to using > > mockups for testing, I need some help to get started. My first attempt > > is to use the AAA syntax that was introduced in version 3.5. I want to > > test the interactions of a class called Presenter. Presenter.Load is > > supposed to call RefreshList on the view member. Let me show the code: > > > namespace CreateFlash.Tests > > { > > using NUnit.Framework; > > using Rhino.Mocks; > > using System.IO; > > using System.Collections.Generic; > > > public interface IView > > { > > void RefreshList(IEnumerable disks); > > } > > > public class Presenter > > { > > private IView view; > > > public Presenter(IView view) > > { > > this.view = view; > > } > > > public void Load() > > { > > this.view.RefreshList(new List() { new > > RemovableDisk("d", "c", 0) }); > > } > > } > > > [TestFixture] > > public class TestPresenter > > { > > [Test] > > public void LoadShouldRefreshListAndCenterInScreen() > > { > > // arrange > > var stubView = MockRepository.GenerateStub(); > > var removableDisks = new List() { new > > RemovableDisk("DeviceID", "Caption", 1000) }; > > > stubView.Stub(x => x.RefreshList(removableDisks)); > > > // act > > var presenterUnderTest = new Presenter(stubView); > > presenterUnderTest.Load(); > > > // assert > > stubView.AssertWasCalled(x => x.RefreshList(removableDisks)); > > } > > } > > > } > > > Coming from a C++ background, the syntax is a bit confusing. I'm not > > sure what to put in Stub and AssertWasCalled. This test fails, > > obviously. How do I verify that Presenter actually calls RefreshList > > in the Load method? Thanks in advance! > > > -- > > Daniel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to RhinoMocks@googlegroups.com To unsubscribe from this group, send email to rhinomocks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/RhinoMocks?hl=en -~--~~~~--~~--~--~---