Here is how you can do it, but at this point, I think that you are not using
Rhino Mocks correctly.
Rhino Mocks is to test interactions of objects, trying to use it to create
complex interaction is possible, but likely to cause complexities down the
road.
[TestFixture]
public class FieldProblem_Adam
{
public interface IFoo
{
string Str { get; set; }
event EventHandler Event;
}
[Test]
public void ShouldRaiseEventWhenEverPropIsSet()
{
var foo = MockRepository.GenerateMock<IFoo>();
foo.Stub(x => x.Str = Arg<string>.Is.Anything)
.WhenCalled(x => foo.Raise(y => y.Event += null, foo,
EventArgs.Empty));
int calls = 0;
foo.Event += delegate
{
calls += 1;
};
foo.Str = "1";
foo.Str = "2";
foo.Str = "3";
foo.Str = "4";
Assert.AreEqual(4, calls);
}
}
On Fri, Nov 14, 2008 at 1:27 AM, Adam <[EMAIL PROTECTED]> wrote:
>
> Well here's a new, clean post. With the following code, how would I
> go about firing off EventFoo each and every time str is assigned to -
> regardless of the value assigned.
>
> Thanks!
>
>
> namespace ConsoleApplication3 {
> class Program {
> static void Main(string[] args) {
> IFoo F = MockRepository.GenerateStub<IFoo>();
>
> }
> }
>
>
> public interface IFoo {
> string str { get; set; }
> event EventHandler EventFoo;
> }
>
>
>
> }
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---