private static EnvironmentConfig Add(
            this EnvironmentConfig config,
            string applicationName,
            string logicalInstanceName,
            string machineName)
        {
            var app = config.Applications.SelectByName(applicationName);
            if (app == null)
            {
                app = new Application(applicationName);
                config.Applications.Add(app);
            }

            var logicalInstance = app.LogicalInstances.SelectByName(logicalInstanceName);
            if (logicalInstance == null)
            {
                logicalInstance = new LogicalInstance(logicalInstanceName);
                app.LogicalInstances.Add(logicalInstance);
            }

            var machine = logicalInstance.Machines.SelectByName(machineName);
            if (machine == null)
            {
                machine = new Machine(machineName);
                logicalInstance.Machines.Add(machine);
            }

            return config;
        }
        public void ExpandMachineGroups_should_remove_duplicate_machine_names()
        {
            var instance =
                new LogicalInstance("MyInstance")
                {
                    Machines =
                    {
                        new Machine("MyGroup"),
                        new Machine("MachineA"),
                        new Machine("MachineC"),
                    }
                };

            var groups = new MachineGroup("MyGroup")
            {
                MachineNames = { "MachineA", "MachineB" }
            };

            instance.ExpandMachineGroups(new[] { groups });

            Assert.AreEqual(3, instance.Machines.Count);
            Assert.AreEqual(1, instance.Machines.Count(m => m.Name == "MachineA"));
            Assert.AreEqual(1, instance.Machines.Count(m => m.Name == "MachineB"));
            Assert.AreEqual(1, instance.Machines.Count(m => m.Name == "MachineC"));
        }
Beispiel #3
0
            private static Application CreateApp(
                string name,
                string instanceName,
                params string[] machineNames)
            {
                var app = new Application(name);
                var instance = new LogicalInstance(instanceName);
                foreach (var machineName in machineNames)
                {
                    instance.Machines.Add(new Machine(machineName));
                }

                app.LogicalInstances.Add(instance);

                return app;
            }