Beispiel #1
0
        public void Dispose_should_mark_endpoint_disposed()
        {
            var endpoint = new Endpoint(Guid.Empty, MonitorMock.Mock("monitor"), "address", "name", "group");

            Assert.False(endpoint.IsDisposed);
            endpoint.Dispose();
            Assert.True(endpoint.IsDisposed);
        }
        public void EndpointRegistry_should_load_endpoints_from_store()
        {
            var endpoint = new Endpoint(Guid.NewGuid(), MonitorMock.Mock("monitor"), "address", "name", "group");

            _configurationStore.Setup(s => s.LoadEndpoints(_monitorRegistry.Object)).Returns(new[] { endpoint });

            var registry = new EndpointRegistry(_monitorRegistry.Object, _configurationStore.Object, _statsRepository.Object);

            Assert.Same(endpoint, registry.GetById(endpoint.Id));
        }
Beispiel #3
0
        public void CheckHealth_should_update_the_endpoint_with_its_health_status()
        {
            var endpoint = new Endpoint(Guid.Empty, MonitorMock.Mock("monitor"), "address", "name", "group");
            var sampler  = new Mock <IHealthSampler>();
            var token    = new CancellationToken();
            var result   = new EndpointHealth(DateTime.UtcNow, TimeSpan.Zero, EndpointStatus.Healthy);

            sampler.Setup(s => s.CheckHealth(endpoint, token)).Returns(Task.FromResult(result));
            endpoint.CheckHealth(sampler.Object, token).Wait();
            Assert.Same(result, endpoint.Health);
        }
        public void GetEndpoints_should_return_all_endpoints()
        {
            var endpoints = new[]
            {
                new Endpoint(Guid.NewGuid(), MonitorMock.Mock("a"), "b", "c", "d"),
                new Endpoint(Guid.NewGuid(), MonitorMock.Mock("e"), "f", "g", "h")
            };

            _endpointRegistry.Setup(r => r.Endpoints).Returns(endpoints);
            var results = _controller.GetEndpoints().ToArray();

            foreach (var endpoint in endpoints)
            {
                AssertEndpoint(endpoint, results.SingleOrDefault(r => r.Id == endpoint.Id));
            }
        }
        public void GetEndpoint_should_return_endpoint_information()
        {
            Guid id       = Guid.NewGuid();
            var  endpoint = new Endpoint(id, MonitorMock.Mock("monitor"), "address", "name", "group");

            _endpointRegistry.Setup(r => r.GetById(id)).Returns(endpoint);

            var result = _controller.GetEndpoint(id) as OkNegotiatedContentResult <EndpointDetails>;

            Assert.NotNull(result);
            AssertEndpoint(endpoint, result.Content);
            Assert.Equal(EndpointStatus.NotRun, result.Content.Status);
            Assert.Equal(null, result.Content.LastCheckUtc);
            Assert.Equal(null, result.Content.LastResponseTime);
            Assert.Equal(new Dictionary <string, string>(), result.Content.Details);
        }
 private void MockMonitor(string monitorType)
 {
     _monitorRegistry
     .Setup(r => r.FindByName(monitorType))
     .Returns(MonitorMock.Mock(monitorType));
 }
 private static MonitorableEndpoint SetupEndpoint(string monitorType)
 {
     return(new MonitorableEndpoint(new EndpointIdentity(Guid.NewGuid(), "blah", "address"), MonitorMock.Mock(monitorType)));
 }
        public async Task CheckHealth_should_update_the_endpoint_with_its_health_status()
        {
            var endpoint = new MonitorableEndpoint(new EndpointIdentity(Guid.Empty, "monitor", "address"), MonitorMock.Mock("monitor"));
            var sampler  = new Mock <IHealthSampler>();
            var token    = new CancellationToken();
            var result   = new EndpointHealth(DateTime.UtcNow, TimeSpan.Zero, EndpointStatus.Healthy);

            sampler.Setup(s => s.CheckHealthAsync(endpoint, token)).Returns(Task.FromResult(result));
            await endpoint.CheckHealth(sampler.Object, token);

            Assert.Same(result, endpoint.Health);
        }
        public void Dispose_should_mark_endpoint_disposed()
        {
            var endpoint = new MonitorableEndpoint(new EndpointIdentity(Guid.Empty, "monitor", "address"), MonitorMock.Mock("monitor"));

            Assert.False(endpoint.IsDisposed);
            endpoint.Dispose();
            Assert.True(endpoint.IsDisposed);
        }