public void Should_map_sucessfully()
 {
     string hostname = "hostname";
     var client = "someClient";
     var freq = 100;
     var configMapper = new ConfigMapper(hostname, stop, dataClientFactory, graphiteClientFactory, log);
     var taskSet = new List<SqlToGraphiteConfigTemplatesWorkItemsTaskSet>();
     var x = new SqlToGraphiteConfigTemplatesWorkItemsTaskSet { frequency = freq.ToString(), Task = new SqlToGraphiteConfigTemplatesWorkItemsTaskSetTask[1] };
     x.Task[0] = new SqlToGraphiteConfigTemplatesWorkItemsTaskSetTask
     {
         client = client,
         connectionstring = "cs",
         name = "name",
         path = "path",
         port = "1234",
         sql = "sql",
         type = "type"
     };
     taskSet.Add(x);
     var clients = new GraphiteClients();
     clients.Add(client, "1234");
     var taskList  = configMapper.Map(taskSet, clients);
     Assert.That(taskList.Count, Is.EqualTo(1));
     Assert.That(taskList[0].Frequency, Is.EqualTo(freq));
     Assert.That(taskList[0].Tasks.Count, Is.EqualTo(1));
     Assert.That(taskList[0].Tasks[0].GetType(), Is.EqualTo(typeof(Task)));
 }
 public void Should_throw_ClientNotFoundException_as_client_is_not_known()
 {
     var name = "name";
     var graphiteClients = new GraphiteClients();
     graphiteClients.Add(name, "1234");
     var ex = Assert.Throws<ClientNotFoundException>(() => graphiteClients.Get("notFound"));
     Assert.That(ex.Message, Is.EqualTo("Client notFound is not known add this into the conifiguration xml"));
 }
 public void Should_not_care_about_client_name_case()
 {
     var name = "name";
     var graphiteClients = new GraphiteClients();
     graphiteClients.Add(name, "1234");
     var client = graphiteClients.Get("NaMe");
     Assert.That(client.Name, Is.EqualTo(name));
     Assert.That(client.Port, Is.EqualTo(1234));
 }
 public void Should_Add_client()
 {
     var name = "name";
     var graphiteClients = new GraphiteClients();
     graphiteClients.Add(name, "1234");
     var client = graphiteClients.Get(name);
     Assert.That(client.Name, Is.EqualTo(name));
     Assert.That(client.Port, Is.EqualTo(1234));
 }
 public ConfigRepository(IConfigReader configReader, ICache cache, ISleep sleep, ILog log,
     int errorReadingConfigSleepTime, IGenericSerializer genericSerializer)
 {
     this.configReader = configReader;
     this.cache = cache;
     this.sleep = sleep;
     ConfigRepository.log = log;
     this.errorReadingConfigSleepTime = errorReadingConfigSleepTime;
     this.genericSerializer = genericSerializer;
     clientList = new GraphiteClients();
     var dir = new DirectoryImpl();
     if (ar == null)
     {
         ar = new AssemblyResolver(dir, log);
     }
     this.masterConfig = new SqlToGraphiteConfig(ar, log);
     this.Hash = "NotSet";
 }
 public void Should_throw_exception_if_graphite_client_is_unknown()
 {
     string hostname = "hostname";
     var configMapper = new ConfigMapper(hostname, stop, dataClientFactory, graphiteClientFactory, log);
     var taskSet = new List<SqlToGraphiteConfigTemplatesWorkItemsTaskSet>();
     var x = new SqlToGraphiteConfigTemplatesWorkItemsTaskSet { frequency = "100", Task = new SqlToGraphiteConfigTemplatesWorkItemsTaskSetTask[1] };
     x.Task[0] = new SqlToGraphiteConfigTemplatesWorkItemsTaskSetTask
         {
             client = "client",
             connectionstring = "cs",
             name = "name",
             path = "path",
             port = "1234",
             sql = "sql",
             type = "typr"
         };
     taskSet.Add(x);
     var clients = new GraphiteClients();
     var ex = Assert.Throws<ClientNotFoundException>(() => configMapper.Map(taskSet, clients));
     Assert.That(ex.Message, Is.EqualTo("Client client is not known add this into the conifiguration xml"));
 }
 private void Init()
 {
     this.errors = new List<string>();
     clientList = new GraphiteClients();
 }
 private void Init()
 {
     this.clients = new List<SqlToGraphiteConfigClientsClient>();
     this.templates = new List<SqlToGraphiteConfigTemplatesWorkItems>();
     this.hosts = new List<SqlToGraphiteConfigHostsHost>();
     this.errors = new List<string>();
     clientList = new GraphiteClients();
 }