Exemple #1
0
        public async Task QueryJSON_WithValidQuery_ReturnsString()
        {
            //  Arrange
            InfluxManager mgr  = new InfluxManager(_influxEndpoint, _influxDatabase, _influxUser, _influxPassword);
            string        data = string.Empty;

            //  Act
            HttpResponseMessage retval = await mgr.QueryJSON("select * from unittest");

            data = await retval.Content.ReadAsStringAsync();

            //  Assert
            Assert.IsNotNull(retval);
            Assert.AreEqual(200, (int)retval.StatusCode);
            Assert.IsTrue(retval.Headers.Contains("X-Influxdb-Version"));

            Assert.IsNotNull(data);
            Assert.IsTrue(data.Length > 0);
        }
Exemple #2
0
        public async Task QueryJSON_WithInvalidDatabase_ReturnsErrorString()
        {
            //  Arrange
            InfluxManager mgr  = new InfluxManager(_influxEndpoint, "invaliddatabase", _influxUser, _influxPassword);
            string        data = string.Empty;

            //  Act
            HttpResponseMessage retval = await mgr.QueryJSON("select bogusfield from unittest");

            data = await retval.Content.ReadAsStringAsync();

            //  Assert
            Assert.IsNotNull(retval);
            Assert.AreEqual(200, (int)retval.StatusCode);
            Assert.IsTrue(retval.Headers.Contains("X-Influxdb-Version"));

            Assert.IsNotNull(data);
            Assert.IsTrue(data.Length > 0);
            Assert.IsTrue(data.Contains("error")); // The JSON should contain an error key
        }
Exemple #3
0
        public async Task QueryJSON_WithValidQueryButNonExistantField_ReturnsString()
        {
            //  Arrange
            InfluxManager mgr  = new InfluxManager(_influxEndpoint, _influxDatabase, _influxUser, _influxPassword);
            string        data = string.Empty;

            //  Act
            HttpResponseMessage retval = await mgr.QueryJSON("select bogusfield from unittest");

            data = await retval.Content.ReadAsStringAsync();

            //  Assert
            Assert.IsNotNull(retval);
            Assert.AreEqual(200, (int)retval.StatusCode);
            Assert.IsTrue(retval.Headers.Contains("X-Influxdb-Version"));

            Assert.IsNotNull(data);                 // We shouldn't have null
            Assert.IsTrue(data.Length > 0);         // We should have something
            Assert.IsTrue(data.Length < 40);        // Just not much
            Assert.IsFalse(data.Contains("error")); //  This shouldn't result in an error
        }
        public async Task QueryJSON_WithInvalidDatabase_ReturnsErrorString()
        {
            //  Arrange
            InfluxManager mgr = new InfluxManager(_influxEndpoint, "invaliddatabase", _influxUser, _influxPassword);
            string data = string.Empty;

            //  Act
            HttpResponseMessage retval = await mgr.QueryJSON("select bogusfield from unittest");
            data = await retval.Content.ReadAsStringAsync();

            //  Assert
            Assert.IsNotNull(retval);
            Assert.AreEqual(200, (int)retval.StatusCode);
            Assert.IsTrue(retval.Headers.Contains("X-Influxdb-Version"));

            Assert.IsNotNull(data);
            Assert.IsTrue(data.Length > 0);
            Assert.IsTrue(data.Contains("error")); // The JSON should contain an error key
        }
        public async Task QueryJSON_WithValidQueryButNonExistantField_ReturnsString()
        {
            //  Arrange
            InfluxManager mgr = new InfluxManager(_influxEndpoint, _influxDatabase, _influxUser, _influxPassword);
            string data = string.Empty;

            //  Act
            HttpResponseMessage retval = await mgr.QueryJSON("select bogusfield from unittest");
            data = await retval.Content.ReadAsStringAsync();

            //  Assert
            Assert.IsNotNull(retval);
            Assert.AreEqual(200, (int)retval.StatusCode);
            Assert.IsTrue(retval.Headers.Contains("X-Influxdb-Version"));

            Assert.IsNotNull(data);
            Assert.IsTrue(data.Length > 0);
            Assert.IsTrue(data.Length < 20);
        }