Пример #1
0
        public void CanReadPostActions()
        {
            var jsonToBe = new
            {
                name        = "TestTemplate",
                identity    = "id",
                shortName   = "test",
                postActions = new[]
                {
                    new
                    {
                        actionId = Guid.NewGuid(),
                    },
                    new
                    {
                        actionId = Guid.NewGuid(),
                    },
                }
            };
            IEngineEnvironmentSettings environmentSettings = _environmentSettingsHelper.CreateEnvironment(virtualize: true);
            string sourceBasePath = environmentSettings.GetNewVirtualizedPath();

            string templateConfigDir = Path.Combine(sourceBasePath, RunnableProjectGenerator.TemplateConfigDirectoryName);
            string filePath          = Path.Combine(templateConfigDir, RunnableProjectGenerator.TemplateConfigFileName);

            environmentSettings.Host.FileSystem.CreateDirectory(templateConfigDir);
            environmentSettings.Host.FileSystem.WriteAllText(filePath, JsonConvert.SerializeObject(jsonToBe));

            IMountPoint mountPoint             = environmentSettings.MountPath(sourceBasePath);
            RunnableProjectGenerator generator = new RunnableProjectGenerator();
            var templates = generator.GetTemplatesAndLangpacksFromDir(mountPoint, out _);

            Assert.Single(templates);
            var template = templates[0];

            Assert.Equal(new[] { jsonToBe.postActions[0].actionId, jsonToBe.postActions[1].actionId }, template.PostActions);
        }