title: unit testing a class with event and delegate
body: <p>I am new to testing please help.</p>
  
  <p>I have the following class</p>
  
  <pre><code>public delegate void OnInvalidEntryMethod(ITnEntry entry, string message);
  
  public class EntryValidator
  {
      public event OnInvalidEntryMethod OnInvalidEntry;
  
      public bool IsValidEntry(ITnEntry entry, string ticker)
      {
          if (!IsFieldValid(entry, ticker.Trim().Length.ToString(), "0"))
              return false;
  
          return true;
      }
  
      private bool IsFieldValid(ITnEntry entry, string actual, string invalidValue)
      {
          if (actual == invalidValue)
          {
              RaiseInvalidEntryEvent(entry);
              return false;
          }
  
          return true;
      }
  
      private void RaiseInvalidEntryEvent(ITnEntry entry)
      {
          if (OnInvalidEntry != null)
              OnInvalidEntry(entry, "Invalid entry in list: " + entry.List.Name + ".");
      }
  }
  </code></pre>
  
  <p>I have written the test case so far but am struggling with the event and delegate as shown below</p>
  
  <pre><code>[TestFixture]
  public class EntryValidatorTests
  {
      private EntryValidator _entryValidator;
  
      private FakeTnEntry _selectedEntry;
      private string _ticker;
  
      [SetUp]
      public void Setup()
      {
          _entryValidator = new EntryValidator();
          _ticker = "BOL";
      }
  
      private FakeTnEntry MakeEntry(string ticker)
      {
          return new FakeTnEntry { Ticker = ticker};
      }
  
      [Test]
      public void IsValidEntry_WithValidValues()
      {
          _selectedEntry = MakeEntry(_ticker);
  
          Assert.IsTrue(_entryValidator.IsValidEntry(_selectedEntry, _selectedEntry.Ticker));
      }
  
      [Test]
      public void IsValidEntry_WithInValidTicker()
      {
          _selectedEntry = MakeEntry("");
          Assert.IsFalse(_entryValidator.IsValidEntry(_selectedEntry, _selectedEntry.Ticker));
      }
  }}
  </code></pre>
  
  <p>Please can someone help? Thanks..</p>