Inheritance: IConfigRepository
 public void SetUp()
 {
     sleepTime = 1000;
     reader = MockRepository.GenerateMock<IConfigReader>();
     cache = MockRepository.GenerateMock<ICache>();
     sleep = MockRepository.GenerateMock<ISleep>();
     log = MockRepository.GenerateMock<ILog>();
     repository = new ConfigRepository(this.reader, new KnownGraphiteClients(), this.cache, this.sleep, this.log, sleepTime);
 }
 public void SetUp()
 {
     sleepTime = 1000;
     assemblyResolver = MockRepository.GenerateMock<IAssemblyResolver>();
     config = new SqlToGraphiteConfig(assemblyResolver, log);
     reader = MockRepository.GenerateMock<IConfigReader>();
     cache = MockRepository.GenerateMock<ICache>();
     sleep = MockRepository.GenerateMock<ISleep>();
     log = MockRepository.GenerateMock<ILog>();
     configPersister = MockRepository.GenerateMock<IConfigPersister>();
     genericSerializer = MockRepository.GenerateMock<IGenericSerializer>();
     repository = new ConfigRepository(this.reader, this.cache, this.sleep, this.log, this.sleepTime, this.configPersister, this.genericSerializer);
 }
 public static TaskManager CreateTaskManager(SqlToGraphiteSection configuration)
 {
     var cacheLength = new TimeSpan(0, configuration.ConfigCacheLengthMinutes, 0);
     var stop = new Stop();
     IDataClientFactory dataClientFactory = new DataClientFactory(log);
     IGraphiteClientFactory graphiteClientFactory = new GraphiteClientFactory(log);
     var configMapper = new ConfigMapper(configuration.Hostname, stop, dataClientFactory, graphiteClientFactory, log);
     var configReader = new ConfigReader(configuration.ConfigUri,configuration.ConfigUsername,configuration.ConfigPassword);
     var cache = new Cache(cacheLength, log);
     var sleeper = new Sleeper();
     var knownGraphiteClients = new KnownGraphiteClients();
     var cr = new ConfigRepository(configReader, knownGraphiteClients, cache, sleeper, log, configuration.MinutesBetweenRetryToGetConfigOnError);
     var configController = new ConfigController(configMapper, log, cr);
     return new TaskManager(log, configController, configuration.ConfigUri, stop, sleeper, configuration.CheckConfigUpdatedEveryMinutes);
 }
        public static TaskManager CreateTaskManager(SqlToGraphiteSection configuration)
        {
            var cacheLength = new TimeSpan(0, configuration.ConfigCacheLengthMinutes, 0);
            var stop = new Stop();
            var directoryImpl = new DirectoryImpl();
            var assemblyResolver = new AssemblyResolver(directoryImpl, log);
            IEncryption encryption = new Encryption();
            IDataClientFactory dataClientFactory = new DataClientFactory(log, assemblyResolver, encryption);
            IGraphiteClientFactory graphiteClientFactory = new GraphiteClientFactory(log);

            var configReader = new ConfigHttpReader(configuration.ConfigUri, configuration.ConfigUsername, configuration.ConfigPassword);
            var cache = new Cache(cacheLength, log);
            var sleeper = new Sleeper();
            var genericSer = new GenericSerializer(Global.GetNameSpace());
            var cr = new ConfigRepository(configReader, cache, sleeper, log, configuration.MinutesBetweenRetryToGetConfigOnError, genericSer);
            var configMapper = new ConfigMapper(configuration.Hostname, stop, dataClientFactory, graphiteClientFactory, log, cr);
            var roleConfigFactory = new RoleConfigFactory();
            var environment = new Environment();
            var taskSetBuilder = new TaskSetBuilder();
            var configController = new ConfigController(configMapper, log, cr, roleConfigFactory, environment, taskSetBuilder);
            return new TaskManager(log, configController, configuration.ConfigUri, stop, sleeper, configuration.CheckConfigUpdatedEveryMinutes);
        }
 public void Should_read_config_One_job_sucessfully_with_unknownplugin()
 {
     IGenericSerializer gs = new GenericSerializer(Global.GetNameSpace());
     repository = new ConfigRepository(this.reader, this.cache, this.sleep, this.log, this.sleepTime, this.configPersister, gs);
     reader.Expect(x => x.GetXml()).Return(Resources.UnknownPlugin);
     cache.Expect(x => x.HasExpired()).Return(true).Repeat.Once();
     //Test
     repository.Load();
     //Assert
     List<Job> jobs = repository.GetJobs();
     Assert.That(jobs.Count, Is.EqualTo(1));
     Assert.That(jobs[0].GetType().Name, Is.EqualTo("WmiClient"));
     genericSerializer.VerifyAllExpectations();
 }
        public void Initialise(string path)
        {
            log = LogManager.GetLogger("log");
            log4net.Config.XmlConfigurator.Configure();

            var sleepTime = 0;
            assemblyResolver = new AssemblyResolver(new DirectoryImpl(), log);
            var config = new SqlToGraphiteConfig(assemblyResolver, log);
            encryption = new Encryption();
            var reader = new ConfigHttpReader(path, "", "");
            var cache = new Cache(new TimeSpan(0, 0, 1, 0), log);
            var sleep = new Sleeper();
            var genericSerializer = new GenericSerializer(Global.GetNameSpace());
            var configPersister = new ConfigPersister(new ConfigFileWriter(path), genericSerializer);

            repository = new ConfigRepository(reader, cache, sleep, this.log, sleepTime, configPersister, genericSerializer);
        }
 public void Should_Add_thing()
 {
     var configRepository = new ConfigRepository(null, null, null, null, 5, null);
     Assert.IsFalse(true);
 }