Esempio n. 1
0
        public MvcHtmlString Container(Action <ContainerSetting> configure)
        {
            var setting = new ContainerSetting();

            configure(setting);

            return(helper.When(JqueryBind.InitIncoding | JqueryBind.IncChangeUrl)
                   .Do()
                   .AjaxGet(setting.Url)
                   .OnSuccess(dsl =>
            {
                dsl.Self().Core().Insert.WithTemplateByUrl(setting.Tmpl).Html();
                dsl.WithId(setting.DependencyId).Core().Trigger.Incoding();
            })
                   .AsHtmlAttributes(new { id = setting.Id })
                   .ToDiv());
        }
        /// <summary>
        /// Creates the docker container.
        /// </summary>
        /// <param name="containerSetting">The container setting.</param>
        /// <param name="containerLabel">The container label.</param>
        private static void CreateDockerContainer(ContainerSetting containerSetting, string containerLabel)
        {
            var imageName             = containerSetting.DatabaseImage;
            var containerReadyMessage = containerSetting.ContainerReadyMessage;

            // 確認指定的 docker image 是否存在
            var imageExists = DockerSupports.CheckImage(imageName);

            if (imageExists.Equals(false))
            {
                Assert.Fail($"docker image {imageName} not exists.");
            }

            // 以指定的 docker image 建立測試用的 container
            var isReady = DockerSupports.CreateContainer(imageName, containerReadyMessage, containerLabel);

            if (isReady.Equals(false))
            {
                Assert.Fail("create docker container failure.");
            }

            // 取得 container 的 ip
            DatabaseIp = imageName.Contains("windows")
                ? DockerSupports.GetContainerIp(DockerSupports.ContainerId)
                : $"127.0.0.1,{DockerSupports.Port}";

            if (string.IsNullOrWhiteSpace(DatabaseIp))
            {
                Assert.Fail("can not get docker container inside ip.");
            }

            // 在 container 裡的 SQL Server 建立測試用 Database
            var connectionString = string.Format(TestDbConnections.Container.Master, DatabaseIp);

            DatabaseCommands.CreateDatabase(connectionString, DatabaseName);
        }