public void ShouldProcessTheCommandsAsExpected(int serial, ControllerConfig config, List <string> commands)
        {
            log($"******** start test #{serial} **********");
            var equipmentController = EquipmentControllerFactory.CreateControllerUsing(config, log);

            var options = new JsonSerializerOptions {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                WriteIndented        = true
            };

            log(JsonSerializer.Serialize <ControllerConfig> (config, options));
            log("");

            log("Initial state:");
            equipmentController.LogStatus();

            foreach (var command in commands)
            {
                log("---------------------------------------------------");
                log($"Input: {command}");
                log("");
                Process(command, equipmentController);
                equipmentController.LogStatus();
                log("");
            }

            log($"******** end test #{serial} **********");
            log("");
            log("---------------------------------------------------");
        }
Example #2
0
        static void Main(string[] args)
        {
            log("Starting Equipment Control System...");

            ControllerConfig config = GetControllerConfiguration(log);

            log("");
            log("Creating and installing equipments...");
            var equipmentController = EquipmentControllerFactory.CreateControllerUsing(config, log);

            log("(Please kill the application to exit.)");
            log("");
            log("Command examples: ");
            log("Command: Movement in Floor 1, Sub corridor 2");
            log("Command: No movement in Floor 1, Sub corridor 2 for a minute");
            log("");

            while (true)
            {
                equipmentController.LogStatus();
                log("---------------------------------------------------");
                var command = input("Command: ");
                log("");
                Process(command, equipmentController);
            }
        }