title: Cannot have two operations in the same contract with the same name : Auto Generated Async Method
body: <p><strong>edit Correction:</strong></p>
  
  <p>My Error was that Instead of using ChatService.IChatService I was using ReflectorLike.ChatServiceReference.IchatService.</p>
  
  <p>In other words , AFAIU <strong>I was referencing a reference</strong> to the Interface rather than the Interface it self. (If you find better way to explain that please suggest them I'll edit the answer later)
  If you run in the same error be sure that you use the correct Interface.</p>
  
  <p><strong>Issue:</strong></p>
  
  <p><strong>The Error:</strong></p>
  
  <blockquote>
    <p>SetUp : System.InvalidOperationException : Cannot have two operations
    in the same contract with the same name, methods ClientConnectAsync
    and ClientConnect in type ReflectorLike.ChatReference.IChatService
    violate this rule. You can change the name of one of the operations by
    changing the method name or by using the Name property of
    OperationContractAttribute.</p>
  </blockquote>
  
  <p><strong>Summary:</strong>
  I tried to do this <a href="https://stackoverflow.com/questions/9587393/recommended-patterns-for-unit-testing-web-services">Recommended patterns for unit testing web services</a></p>
  
  <p>But my mocked service throws me an exception because all my methods have twins with same name for instance it has both ClientConnect and ClientConnectAsync which violate WCF Service Rule</p>
  
  <p>I have a service which interface is</p>
  
  <pre><code>namespace ChatService
  {
      [ServiceContract]
      public interface IChatService
      {
          [OperationContract]
          ChatUser ClientConnect(string userName);
  
          [OperationContract]
          void SendNewMessage(ChatMessage newMessage);
  
          [OperationContract]
          List&lt;ChatUser&gt; GetAllUsers();
  
          [OperationContract]
          void RemoveUser(ChatUser user);
  
          [OperationContract]
          List&lt;ChatMessage&gt; GetNewMessages(ChatUser user);
      }
  
  
      [DataContract]
      public class ChatMessage
      {
          [DataMember]
          public ChatUser User { get; set; }
  
          [DataMember]
          public string Message { get; set; }
  
          private DateTime date;
          [DataMember]
          public DateTime Date
          {
              get { return date; }
              set { date = value; }
          }
      }
  
      /// &lt;summary&gt;
      /// 
      /// &lt;/summary&gt;
      [DataContract]
      public class ChatUser
      {
          [DataMember]
          public string UserName { get; set; }
  
          [DataMember]
          public string IpAddress { get; set; }
  
          [DataMember]
          public string HostName { get; set; }
  
  
          public ChatUser(string userName)
          {
              this.UserName = userName;
          }
  
          public override string ToString()
          {
              return this.UserName;
          }
      }
  
  
  }
  </code></pre>
  
  <p>I want to test my client using a mock service so I Test it with nunit and nsubstitute</p>
  
  <pre><code>    namespace ReflectorLike.Tests
  {
      [TestFixture]
      internal class ChatHubTester
      {
  
          private ChatHub hub;
          private ServiceHost host;
          private IChatService myMockedService;
          [SetUp]
          public void SetUp()
          {
              Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add&lt;ServiceContractAttribute&gt;();
              myMockedService = Substitute.For&lt;IChatService&gt;();
              host = MockServiceHostFactory.GenerateMockServiceHost(myMockedService, new Uri("http://localhost:12345"), "ServiceEndPoint");
              host.Open();
              hub=new ChatHub();
          }
  
          [TearDown]
          public void TearDown()
          {
              host.Close();
          }
  
  
  
  
          [Test]
          public void SomeTest()
          {
  
              hub.Connect("Test");
          }
      }
  }
  </code></pre>