﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on Rhino Mocks Events: Purity vs. Practicality</title><description>What version did you get? 3.1?
  
It should definitely be there
</description><link>http://ayende.com/2531/rhino-mocks-events-purity-vs-practicality#comment4</link><guid>http://ayende.com/2531/rhino-mocks-events-purity-vs-practicality#comment4</guid><pubDate>Wed, 13 Jun 2007 02:01:18 GMT</pubDate></item><item><title>irfan commented on Rhino Mocks Events: Purity vs. Practicality</title><description>i downloaded the latest version of Rhino mock. but could find the the interface IEventRaiser.
  
what could be the probelm.
  
i shifted from NMock because there is no event support for nmock.
</description><link>http://ayende.com/2531/rhino-mocks-events-purity-vs-practicality#comment3</link><guid>http://ayende.com/2531/rhino-mocks-events-purity-vs-practicality#comment3</guid><pubDate>Wed, 13 Jun 2007 01:57:53 GMT</pubDate></item><item><title>Ayende Rahien commented on Rhino Mocks Events: Purity vs. Practicality</title><description> Aaron,
  
Nice syntax, but it is very un-natural thing to do.
  
Still, something to remember for sure.
</description><link>http://ayende.com/2531/rhino-mocks-events-purity-vs-practicality#comment2</link><guid>http://ayende.com/2531/rhino-mocks-events-purity-vs-practicality#comment2</guid><pubDate>Sat, 09 Jun 2007 03:36:06 GMT</pubDate></item><item><title>Aaron Jensen commented on Rhino Mocks Events: Purity vs. Practicality</title><description>I sent you an email about this about something like this a year ago... I don't remember if you responded, but basically I suggested syntax like this:
  
  
obj.Bar += mocks.Raise&lt;Foo&gt;(EventArgs.Empty);
  
  
and behind the scenes it would look kind of like this:
  
  
// Obj class:
  
    private object[] _args = null;
  
    private bool _raise;
  
  
    delegate void Foo(string hi);
  
    private event Foo BarBack;
  
    private event Foo Bar
  
    {
  
      add 
  
      { 
  
        // if playing back:
  
        if (_raise)
  
        {
  
          BarBack.DynamicInvoke(_args);
  
  
          _raise = false; 
  
        }
  
      }
  
      remove { }
  
    }
  
  
  
  
// MockRepository:
  
  
    private T Raise&lt;T&gt;(params object[] args) where T : class
  
    {
  
      _args = args;
  
      _raise = true;
  
  
      return null;
  
    }
  
  
So basically you'd set the flag and then ignore the next call to an event but actually raise the event instead. Kind of hacky, but it gets rid of strings.
</description><link>http://ayende.com/2531/rhino-mocks-events-purity-vs-practicality#comment1</link><guid>http://ayende.com/2531/rhino-mocks-events-purity-vs-practicality#comment1</guid><pubDate>Fri, 08 Jun 2007 21:15:20 GMT</pubDate></item></channel></rss>