Ejemplo n.º 1
0
        public async Task WaitAsync_Ready_IsReady()
        {
            //act
            Mock <IDockerContainerManager> managerMock = ArrangeContainerManagerMock();

            var initilizer = new ContainerInitializer(
                managerMock.Object,
                ContainerResourceBuilder.New()
                .WaitTimeout(7)
                .Build());

            // act
            Status result = await initilizer.WaitAsync(new OneThrowStatusProvider());


            // assert
            result.IsReady.Should().BeTrue();
        }
Ejemplo n.º 2
0
        public async Task WaitAsync_NotReady_Throws()
        {
            //act
            Mock <IDockerContainerManager> managerMock = ArrangeContainerManagerMock();

            var initilizer = new ContainerInitializer(
                managerMock.Object,
                ContainerResourceBuilder.New()
                .WaitTimeout(3)
                .Build());

            // act
            Func <Task> action = async()
                                 => await initilizer.WaitAsync(new NotReadyStatusProvider());

            // assert
            await action.Should().ThrowAsync <InvalidOperationException>();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes the resources
        /// </summary>
        public async virtual Task InitializeAsync()
        {
            ResourceOptions = new TOptions();
            var builder = ContainerResourceBuilder.New();

            ResourceOptions.Configure(builder);
            Settings = builder.Build();

            SetComposeVariables();
            OnSettingsBuilded(Settings);
            ValidateSettings(Settings);

            DockerConfiguration dockerConfig = Settings.DockerConfigResolver();

            Manager     = new DockerContainerManager(Settings, dockerConfig);
            Initializer = new ContainerInitializer(Manager, Settings);
            await Manager.CreateAndStartContainerAsync();
        }
Ejemplo n.º 4
0
        public async Task WaitAsync_Ready_IsReadyAndConsumeLogsCalledOnce()
        {
            //act
            Mock <IDockerContainerManager> managerMock = ArrangeContainerManagerMock();

            var initilizer = new ContainerInitializer(
                managerMock.Object,
                ContainerResourceBuilder.New()
                .WaitTimeout(7)
                .Build());

            // act
            Status result = await initilizer.WaitAsync(new OneThrowStatusProvider());


            // assert
            result.IsReady.Should().BeTrue();
            managerMock.Verify(m => m.ConsumeLogsAsync(It.IsAny <TimeSpan>()),
                               Times.Once);
        }