Пример #1
0
        public void MicroserviceValidationTest()
        {
            var service = new Microservice()
            {
                Endpoints = null
            };

            var result = service.Validate();

            Assert.IsFalse(result);
        }
Пример #2
0
        public void MicroserviceWithoutEndpointsTest()
        {
            var service = new Microservice()
            {
                Endpoints = new List <Endpoint>()
            };

            var result = service.Validate();

            Assert.IsFalse(result);
        }
Пример #3
0
        /// <summary>
        /// Register the specified service and all its endpoints.
        /// </summary>
        /// <param name="service">Service.</param>
        public bool Register(Microservice service)
        {
            var isValid = service.Validate();

            if (!isValid)
            {
                return(false);
            }

            // Add the microservice.
            this.microservices.TryAdd(service.ID, service);

            // Add all the endpoints exposed by this service.
            foreach (var endpoint in service.Endpoints)
            {
                endpoint.Microservice = service;
                this.endpoints.TryAdd(endpoint.Signature, service.ID);
            }

            // Succesfull if we've made it this far.
            return(true);
        }