예제 #1
0
        public void CreateADispatcher()
        {
            Mock <IHttpCommandSerializer>  serializer             = new Mock <IHttpCommandSerializer>();
            Mock <IUriCommandQueryBuilder> uriCommandQueryBuilder = new Mock <IUriCommandQueryBuilder>();
            Mock <IHttpClientProvider>     httpClientProvider     = new Mock <IHttpClientProvider>();

            HttpCommandDispatcherFactory testSubject = new HttpCommandDispatcherFactory(serializer.Object,
                                                                                        uriCommandQueryBuilder.Object,
                                                                                        httpClientProvider.Object);
            ICommandDispatcher dispatcher = testSubject.Create(new Uri("http://localhost"));

            Assert.IsType <HttpCommandDispatcher>(dispatcher);
            Assert.IsType <HttpCommandExecuter>(dispatcher.AssociatedExecuter);
        }
예제 #2
0
        static ICommandDispatcher Configure()
        {
            Uri uri = new Uri("http://localhost:52933/api/personalDetails");
            ServiceCollection serviceCollection = new ServiceCollection();
            CommandingDependencyResolverAdapter dependencyResolver = serviceCollection.GetCommandingDependencyResolver(() => _serviceProvider);

            ICommandRegistry registry = dependencyResolver.AddCommanding();

            dependencyResolver.AddHttpCommanding();
            _serviceProvider = serviceCollection.BuildServiceProvider();

            registry.Register <UpdatePersonalDetailsCommand, UpdateResult>(HttpCommandDispatcherFactory.Create(uri, HttpMethod.Put));

            ICommandDispatcher dispatcher = _serviceProvider.GetService <ICommandDispatcher>();

            return(dispatcher);
        }
예제 #3
0
 public static ICommandRegistry AddProductClient(this ICommandRegistry commandRegistry, Uri endpoint)
 {
     commandRegistry.Register <GetProductQuery>(HttpCommandDispatcherFactory.Create(endpoint, HttpMethod.Get));
     return(commandRegistry);
 }