Ejemplo n.º 1
0
        public string GetContainerByName(string Name)
        {
            var containers = _docker.GetContainers(filter: $" -f name={Name}");

            if (containers.Count == 1)
            {
                return(containers.FirstOrDefault().Id);
            }
            return(null);
        }
        public void GetContainersShallWork()
        {
            // Arrange
            using (var container = _host.Create("postgres:9.6-alpine"))
                using (var container2 = _host.Create("postgres:9.6-alpine"))
                {
                    container.Start();

                    // Act
                    var result = _host.GetContainers(true);

                    // Assert
                    Assert.IsNotNull(result.SingleOrDefault(c => c.Id == container.Id &&
                                                            JsonConvert.SerializeObject(c) == JsonConvert.SerializeObject(container)));
                    Assert.IsNotNull(result.SingleOrDefault(c => c.Id == container2.Id &&
                                                            JsonConvert.SerializeObject(c) == JsonConvert.SerializeObject(container2)));
                }
        }