Ejemplo n.º 1
0
        public void ClimateController_IClimateSources_are_of_correct_type()
        {
            ConfigurationBuilder builder = new ConfigurationBuilder();

            builder.AddEnvironmentVariables();

            IConfigurationRoot      Configuration = builder.Build();
            IOptions <AppKeyConfig> options       = Options.Create(new AppKeyConfig()
            {
                UserName            = Configuration["NETATMO_USERNAME"],
                Password            = Configuration["NETATMO_PASSWORD"],
                NetatmoClientId     = Configuration["NETATMO_CLIENTID"],
                NetatmoClientSecret = Configuration["NETATMO_CLIENTSECRET"],
                NibeClientId        = Configuration["NIBE_ID"],
                NibeClientSecret    = Configuration["NIBE_SECRET"],
                NibeRedirectURI     = Configuration["NIBE_REDIRECTURL"],
                NibeHost            = Configuration["NIBE_HOST"],
                NetatmoHost         = Configuration["NETATMO_HOST"],
                BuildVersion        = Configuration["BUILD_VERSION"]
            });

            ConcurrentDictionary <string, IClimateSource> sources = new ConcurrentDictionary <string, IClimateSource>();
            NibeUnit nibeUnit = new NibeUnit();

            sources["Nibe"]    = nibeUnit;
            sources["Netatmo"] = new NetatmoUnit();
            LoggerFactory loggerFactory = new LoggerFactory();

            loggerFactory.AddConsole();
            ILogger <ClimateController> logger            = new Logger <ClimateController>(loggerFactory);
            ClimateController           climateController = new ClimateController(options, sources, logger);

            Assert.IsType <NetatmoUnit>(climateController.netatmo);
            Assert.IsType <NibeUnit>(climateController.nibe);
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOptions();
            services.AddCors();
            services.Configure <AppKeyConfig>(configs =>
            {
                configs.UserName            = Configuration["NETATMO_USERNAME"];
                configs.Password            = Configuration["NETATMO_PASSWORD"];
                configs.NetatmoClientId     = Configuration["NETATMO_CLIENTID"];
                configs.NetatmoClientSecret = Configuration["NETATMO_CLIENTSECRET"];
                configs.NibeClientId        = Configuration["NIBE_CLIENTID"];
                configs.NibeClientSecret    = Configuration["NIBE_CLIENTSECRET"];
                configs.NibeRedirectURI     = Configuration["NIBE_REDIRECTURL"];
                configs.NibeHost            = Configuration["NIBE_HOST"];
                configs.NetatmoHost         = Configuration["NETATMO_HOST"];
                configs.BuildVersion        = Configuration["BUILD_VERSION"];
            });


            // Add framework services.
            services.AddMvc();

            ConcurrentDictionary <string, IClimateSource> sources = new ConcurrentDictionary <string, IClimateSource>();

            //NibeUnit nibe = new NibeUnit() { CodeFilePath = "data/code.txt"};

            sources["Nibe"] = new NibeUnit()
            {
                CodeFilePath = "data/code.txt"
            };
            sources["Netatmo"] = new NetatmoUnit();
            services.AddSingleton <IDictionary <string, IClimateSource> > (sources);
        }