示例#1
0
        // By default, returns two configurations: one with just the system modules; the other with
        // the full configuration (if it contains more than just system modules). The first
        // configuration can be deployed in advance to ensure edgeHub's routes are ready before the
        // test modules start sending messages, to avoid dropped messages.
        // Note: Another option would be to define all possible routes at the beginning of the test
        // run, but then module names would need to be statically defined as well (currently they're
        // dynamic).
        // If stageSystemModules is false, returns one (full) configuration.
        public IEnumerable <EdgeConfiguration> Build(bool stageSystemModules = true)
        {
            // Edge agent is not optional; add if necessary
            if (!this.moduleBuilders.ContainsKey(ModuleName.EdgeAgent))
            {
                this.AddEdgeAgent();
            }

            ILookup <string, ModuleConfiguration> moduleConfigs = this.moduleBuilders
                                                                  .Where(b => b.Key != ModuleName.EdgeAgent) // delay building edge agent
                                                                  .Select(b => b.Value.Build())
                                                                  .ToLookup(m => m.IsSystemModule() ? "system" : "other");

            EdgeConfiguration BuildEdgeConfiguration(List <ModuleConfiguration> modules)
            {
                modules.Insert(0, this.BuildEdgeAgent(modules));
                return(EdgeConfiguration.Create(this.deviceId, modules));
            }

            if (stageSystemModules)
            {
                // Return a configuration for $edgeHub and $edgeAgent
                yield return(BuildEdgeConfiguration(moduleConfigs["system"].ToList()));

                if (moduleConfigs.Contains("other"))
                {
                    // Return a configuration for all modules
                    yield return(BuildEdgeConfiguration(moduleConfigs.SelectMany(m => m).ToList()));
                }
            }
            else
            {
                yield return(BuildEdgeConfiguration(moduleConfigs.SelectMany(m => m).ToList()));
            }
        }
示例#2
0
        public EdgeConfiguration Build()
        {
            // Edge agent is not optional; add if necessary
            if (!this.moduleBuilders.ContainsKey(ModuleName.EdgeAgent))
            {
                this.AddEdgeAgent();
            }

            List <ModuleConfiguration> moduleConfigs = this.moduleBuilders
                                                       .Where(b => b.Key != ModuleName.EdgeAgent) // delay building edge agent
                                                       .Select(b => b.Value.Build())
                                                       .ToList();

            moduleConfigs.Insert(0, this.BuildEdgeAgent(moduleConfigs));
            return(EdgeConfiguration.Create(this.deviceId, moduleConfigs));
        }