public void Should_get_results()
 {
     var param = new TaskParams("path", "SELECT [dbms_id] FROM [msdb].[dbo].[MSdbms]", ConnectionString, "SqlServer", "name", "statsdudp");
     var log = MockRepository.GenerateMock<ILog>();
     var sqlServerClient = new SqlServerClient(log, param);
     var results = sqlServerClient.Get();
     Assert.That(results.Count, Is.EqualTo(8));
 }
 public void Should_get_result()
 {
     var name = Guid.NewGuid().ToString();
     var param = new TaskParams("path", "SELECT COUNT(*) as count FROM [master].[dbo].[spt_monitor]", ConnectionString, "SqlServer", name, "Statsdudp");
     var log = MockRepository.GenerateMock<ILog>();
     var sqlServerClient = new SqlServerClient(log, param);
     //Test
     var results = sqlServerClient.Get();
     //Asset
     Assert.That(results.Count, Is.EqualTo(1));
     Assert.That(results[0].Name, Is.EqualTo(name));
     Assert.That(results.Count, Is.EqualTo(1));
 }
        public void Should_get_results()
        {
            var metricName = Guid.NewGuid().ToString();
            var serverClientParams = new SqlServerClient
            {
                ConnectionString = e.Encrypt(ConnectionString),
                Path = SimplePath,
                Sql = "SELECT [dbms_id] FROM [msdb].[dbo].[MSdbms]",
                ClientName = "GraphiteTcpClient",
            };

            var sqlServerClient = new SqlServerClient(log, serverClientParams,encryption);
            var results = sqlServerClient.Get();
            Assert.That(results.Count, Is.EqualTo(8));
        }
 public void Should_get_result_with_date_and_name_set_in_select()
 {
     var name = Guid.NewGuid().ToString();
     var param = new TaskParams("path", "SELECT 234 , DATEADD(day,11,GETDATE()), 'someName'", ConnectionString, "SqlServer", name, "statsdudp");
     var log = MockRepository.GenerateMock<ILog>();
     var sqlServerClient = new SqlServerClient(log, param);
     //Test
     var results = sqlServerClient.Get();
     //Asset
     var futureDate = DateTime.Now.Add(new TimeSpan(11, 0, 0, 0));
     Assert.That(results.Count, Is.EqualTo(1));
     Assert.That(results[0].Name, Is.EqualTo("someName"));
     Assert.That(results[0].Path, Is.EqualTo("path"));
     Assert.That(results[0].Value, Is.EqualTo(234));
 }
        public void Should_get_result()
        {
            var metricName = Guid.NewGuid().ToString();
            var serverClientParams = new SqlServerClient
                {
                    ConnectionString = e.Encrypt(ConnectionString),
                    Path = SimplePath,
                    Sql = SimpleQuery,
                    ClientName = "GraphiteTcpClient",
                };

            var sqlServerClient = new SqlServerClient(log, serverClientParams, encryption);
            //Test
            var results = sqlServerClient.Get();
            //Asset
            Assert.That(results.Count, Is.EqualTo(1));
            Assert.That(results[0].Path, Is.EqualTo(SimplePath));
            Assert.That(results[0].Value, Is.EqualTo("234"));
        }
        public void Should_get_result_with_date()
        {
            var name = Guid.NewGuid().ToString();
            var param = new TaskParams(
                "path", "SELECT 234 , DATEADD(day,11,GETDATE())", ConnectionString, "SqlServer", name, "statsdudp");

            var log = MockRepository.GenerateMock<ILog>();
            var sqlServerClient = new SqlServerClient(log, param);
            //Test
            var results = sqlServerClient.Get();
            //Asset
            var futureDate = DateTime.Now.Add(new TimeSpan(11, 0, 0, 0));
            Assert.That(results.Count, Is.EqualTo(1));
            Assert.That(results[0].Name, Is.EqualTo(name));
            Assert.That(results[0].Value, Is.EqualTo(234));
            Assert.That(results[0].TimeStamp.Day, Is.EqualTo(futureDate.Day));
            Assert.That(results[0].TimeStamp.Hour, Is.EqualTo(futureDate.Hour));
            Assert.That(results[0].TimeStamp.Minute, Is.EqualTo(futureDate.Minute));
            Assert.That(results[0].TimeStamp.Year, Is.EqualTo(futureDate.Year));
        }
        public void Should_get_result_with_date()
        {
            var metricName = Guid.NewGuid().ToString();
            var serverClientParams = new SqlServerClient
            {
                ConnectionString = e.Encrypt(ConnectionString),
                Path = SimplePath,
                Sql = SimpleQuery,
                ClientName = "GraphiteTcpClient",
            };

            var sqlServerClient = new SqlServerClient(log, serverClientParams,encryption);
            //Test
            var results = sqlServerClient.Get();
            //Asset
            var futureDate = DateTime.Now.Add(new TimeSpan(11, 0, 0, 0));
            Assert.That(results.Count, Is.EqualTo(1));
            Assert.That(results[0].Path, Is.EqualTo(SimplePath));
            Assert.That(results[0].Value, Is.EqualTo("234"));
            Assert.That(results[0].TimeStamp.Day, Is.EqualTo(futureDate.Day));
            Assert.That(results[0].TimeStamp.Hour, Is.EqualTo(futureDate.Hour));
            Assert.That(results[0].TimeStamp.Minute, Is.EqualTo(futureDate.Minute));
            Assert.That(results[0].TimeStamp.Year, Is.EqualTo(futureDate.Year));
        }
        public void Should_get_result_with_date_and_name_set_in_select()
        {
            var metricName = Guid.NewGuid().ToString();
            var serverClientParams = new SqlServerClient
            {
                ConnectionString = e.Encrypt(ConnectionString),
                Path = SimplePath,
                Sql = "SELECT 234 , DATEADD(day,11,GETDATE()), 'someName'",
                ClientName = "GraphiteTcpClient",
            };

            var sqlServerClient = new SqlServerClient(log, serverClientParams, encryption);
            //Test
            var results = sqlServerClient.Get();
            //Asset
            var futureDate = DateTime.Now.Add(new TimeSpan(11, 0, 0, 0));
            Assert.That(results.Count, Is.EqualTo(1));
            Assert.That(results[0].Name, Is.EqualTo("someName"));
            Assert.That(results[0].Path, Is.EqualTo(SimplePath));
            Assert.That(results[0].Value, Is.EqualTo("234"));
        }