public void AddService_registers_a_new_Service()
        {
            var node = new Node
                {
                    Ip = "127.1.1.1"
                };

            var allservices = _nodeProvider.GetAllAvailableServices();

            Assert.IsTrue(!allservices.Any());
            _nodeProvider.AddService(node);
            Assert.IsTrue(allservices.Count() == 1);
        }
 /// <summary>
 /// Adds the service.
 /// </summary>
 /// <param name="service">The service.</param>
 public void AddService(Node service)
 {
     AllServices.Add(service);
 }
示例#3
0
        /// <summary>
        /// Tries the connect.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <exception cref="System.ArgumentNullException">node</exception>
        /// <exception cref="System.IO.InvalidDataException">Ip</exception>
        public void TryConnect(Node node)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            if(!IsIPV4(node.Ip))
                throw new InvalidDataException("Ip");

            var address = IPAddress.Parse(node.Ip);

             _client.Connect(address, node.Port);
        }
示例#4
0
        /// <summary>
        /// Services the outage.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">service</exception>
        public bool ServiceOutage(Node service)
        {
            if(service == null)
                throw new ArgumentNullException("service");

            var now = DateTimeOffset.UtcNow;

            if ((now > service.OutageStartTime) && (now < service.OutageEndTime))
            {
                return true;
            }
            return false;
        }
 public void IsServiceOutage_Should_only_check_if_outage_is_set()
 {
     var node = new Node();
     var isOutage = _connection.ServiceOutage(node);
     Assert.IsFalse(isOutage);
 }
 public void IsServiceOutage_Can_detect_service_outage()
 {
     var node = new Node
         {
             Ip = "127.0.0.1",
             Port = 11111,
             OutageStartTime = DateTimeOffset.UtcNow.AddHours(-1),
             OutageEndTime = DateTimeOffset.UtcNow.AddHours(1)
         };
     var isOutage = _connection.ServiceOutage(node);
     Assert.IsTrue(isOutage);
 }