public void Can_only_map_interfaces_using_generic_method()
        {
            // When
            Action mappingNonInterface = () => hub.MapClientMethods <object>(client);

            // Then
            mappingNonInterface.ShouldThrow <InvalidOperationException>();
        }
 public void SetUp()
 {
     hubConnection = new HubConnection(TestHubSite.Url);
     hub           = hubConnection.CreateHubProxy("TestHub");
     client        = A.Fake <ITestHubClient>();
     hub.MapClientMethods <ITestHubClient>(client);
     hubConnection.Start().Wait();
 }
        public static void MapClientMethods <T>(this IHubProxy hub, object hubClient)
        {
            if (!typeof(T).GetTypeInfo().IsInterface)
            {
                throw new InvalidOperationException("The generic type parameter T must be an interface when mapping client methods.");
            }
            if (!(hubClient is T))
            {
                throw new ArgumentException(String.Format("The hubClient must implement the interface from the generic type parameter: {0}", typeof(T)));
            }

            var methods = typeof(T).GetMethods();

            hub.MapClientMethods(hubClient, methods);
        }