Example #1
0
        public GetServiceUrlResponse GetServiceUrl(string name, string version)
        {
            var request = new GetServiceUrlRequest
            {
                ServiceName    = name,
                ServiceVersion = version
            };

            var result = pipelineFactory.Get <GetServiceUrlRequest, GetServiceUrlResponse>().Execute(request).Result;

            return(result);
        }
Example #2
0
        public void Execute_ShouldReturnUrlOfService()
        {
            const string testServiceName = "Test Service";
            const string version         = "v1";
            const string url             = "http://bogus/";

            var services = new List <ServiceConfigurationDto>
            {
                new ServiceConfigurationDto
                {
                    Name    = testServiceName,
                    Url     = url,
                    Version = version
                }
            };

            var repositoryResponse = new GetServicesResponse
            {
                Services = services
            };

            var repositoryMock = new Mock <IServiceRepository>();

            repositoryMock.Setup(x => x.GetServices()).Returns(repositoryResponse);

            ScopeAction action = scope =>
            {
                var request = new GetServiceUrlRequest()
                {
                    ServiceName = testServiceName, ServiceVersion = version
                };

                var response = scope.Resolve <GetServiceUrlCommand>().Execute(request, new Dictionary <string, object>());

                Assert.IsNotNull(response);
                Assert.AreEqual(url, response.ServiceUrl);
            };

            RunAction(action, builder =>
            {
                builder.RegisterInstance(repositoryMock.Object).As <IServiceRepository>();

                builder.RegisterType <GetServiceUrlCommand>()
                .AsImplementedInterfaces()
                .AsSelf()
                .PropertiesAutowired();
            });
        }