Esempio n. 1
0
        public void Extension_Send_string_double_timestamp_Ok()
        {
            var mockClient = new Mock <IGraphiteClient>();

            mockClient.Setup(x => x.Send(It.IsAny <string>(), It.IsAny <double>(), It.IsAny <DateTime>()));
            var graphite = _context.Graphite(_settings, mockClient.Object);

            Assert.IsInstanceOf <Graphite>(graphite);
            Assert.DoesNotThrow(() =>
            {
                GraphiteExtensions.Send(graphite, "test", 1, DateTime.UtcNow);
            });
        }
Esempio n. 2
0
        public void Extension_Send_string_double_Throws_Ok()
        {
            var mockClient = new Mock <IGraphiteClient>();

            mockClient.Setup(x => x.Send(It.IsAny <string>(), It.IsAny <double>())).Throws <Exception>();
            _settings.ThrowExceptions = false;
            var graphite = _context.Graphite(_settings, mockClient.Object);

            Assert.IsInstanceOf <Graphite>(graphite);
            Assert.DoesNotThrow(() =>
            {
                GraphiteExtensions.Send(graphite, "test", 1);
            });
        }
Esempio n. 3
0
        public void Extension_Send_string_double_timestamp_Throws()
        {
            var mockClient = new Mock <IGraphiteClient>();

            mockClient.Setup(x => x.Send(It.IsAny <string>(), It.IsAny <double>(), It.IsAny <DateTime>())).Throws <Exception>();
            _settings.ThrowExceptions = true;
            var graphite = _context.Graphite(_settings, mockClient.Object);

            Assert.IsInstanceOf <Graphite>(graphite);
            try
            {
                GraphiteExtensions.Send(graphite, "test", 1, DateTime.Now);
                Assert.Fail($"{nameof(Extension_Send_string_double_timestamp_Throws)} should have thrown an exception");
            }
            catch
            {
                Assert.Pass();
            }
        }
Esempio n. 4
0
        public void Extension_Send_Collection_Datapoint_Throws()
        {
            var mockClient = new Mock <IGraphiteClient>();

            mockClient.Setup(x => x.Send(It.IsAny <Datapoint[]>())).Throws <Exception>();
            mockClient.Setup(x => x.Send(It.IsAny <ICollection <Datapoint> >())).Throws <Exception>();
            _settings.ThrowExceptions = true;
            var graphite = _context.Graphite(_settings, mockClient.Object);

            Assert.IsInstanceOf <Graphite>(graphite);
            try
            {
                GraphiteExtensions.Send(graphite, new Collection <Datapoint> {
                    new Datapoint("test", 1, DateTime.UtcNow)
                });
                Assert.Fail($"{nameof(Extension_Send_Collection_Datapoint_Throws)} should have thrown an exception");
            }
            catch
            {
                Assert.Pass();
            }
        }