title: Mocking a singleton c# class in nunit
body: <p>I have a class, something like this:-</p>
  
  <pre><code>namespace CalendarIntegration.Google
  {
      public sealed class GoogleSyncEventProcessor : ICalendarSyncEventProcessor
      {
  
  public void ProcessEventRequest(object events, int soUserId, string calendarId, bool addLogs = false)
          {
              if (GoogleWatchManager.Instance.IsGoogleTwoWaySynLive)
              {
  </code></pre>
  
  <p>GoogleWatchManager is further a sealed class.</p>
  
  <pre><code>namespace CalendarIntegration.Google
  {
      public sealed class GoogleWatchManager
      {
          readonly bool isGoogleTwoWaySyncLive = true;
          public GoogleWatchManager()
          {
                     isGoogleTwoWaySyncLive = false;
          }
  
   virtual public bool IsGoogleTwoWaySynLive
          {
              get { return isGoogleTwoWaySyncLive; }
          }
  </code></pre>
  
  <p>I want fake/mock GoogleWatchManager class and make the value of <code>GoogleWatchManager.Instance.IsGoogleTwoWaySynLive</code> in the nunit test cases, by default it is true in GoogleWatchManager class.</p>
  
  <p>I tried the below but it doesn't work-</p>
  
  <pre><code>using EFBL;
  using NUnit.Framework;
  using EFBL.CalendarIntegration.CalendarSync;
  using EFBL.CalendarIntegration.Google;
  using Moq;
  
  namespace EFBL.CalendarIntegration.Google
  {
      [TestFixture]
      public class GoogleSyncEventProcessorSpec
      {
          public GoogleSyncEventProcessor google;
          public GoogleWatchManager googleManager;
  
          public void SetUp()
          {
          }
  
          [Test]
          public void ProcessEventRequest_NoEvents_ExceptionThrown()
          {
              var mock = new Mock&lt;GoogleWatchManager&gt;();
              mock.SetupGet(foo =&gt; foo.IsGoogleTwoWaySynLive).Returns(true);
              //             watch.Setup(i =&gt; i.IsGoogleTwoWaySynLive).Returns(false);
              // var mock = new Mock&lt;GoogleWatchManager&gt;().Object;
              GoogleSyncEventProcessor obj = GoogleSyncEventProcessor.Instance;
  
              obj.ProcessEventRequest(null, -1, "");
              //            isGoogleTwoWaySyncLive
          }
      }
  }
  </code></pre>
  
  <p>Any help is highly appreciated, thanks in advance.</p>