public void TestDockerExceptionHandledOnKill() { // Arrange var containerApiMock = new Mock <IContainerApi>(); // Mock ContainerInspect API containerApiMock.Setup(m => m.ContainerKill(TEST_RUNSPACE_ID, null)) .Throws(new ApiException()); var containerApi = containerApiMock.Object; var dockerRunspaceProvider = new DockerRunspaceProvider( new RunspaceContainerCreateSpec() { ImageName = TEST_IMAGE_NAME, NetworkName = TEST_NETWORK_NAME }, TEST_DOCKER_ADDRESS, containerApi, false); // Act && Assert Assert.Throws <RunspaceProviderException>( () => dockerRunspaceProvider.Kill(TEST_RUNSPACE_ID), "Docker Engine ContainerKill API failed"); }
//[Test] public void TestKillRunsapceContainer() { // Arrange var runspaceInfo = _runspaceProvider.StartCreate(); runspaceInfo = _runspaceProvider.WaitCreateCompletion(runspaceInfo); // Act _runspaceProvider.Kill(runspaceInfo.Id); // Assert var runningContainers = _containerApi.ContainerList(); Assert.IsEmpty(runningContainers); }
public void TestKill() { // Arrange var containerApiMock = new Mock <IContainerApi>(); containerApiMock.Setup(m => m.ContainerKill(TEST_RUNSPACE_ID, null)); var dockerRunspaceProvider = new DockerRunspaceProvider( new RunspaceContainerCreateSpec() { ImageName = TEST_IMAGE_NAME, NetworkName = TEST_NETWORK_NAME }, TEST_DOCKER_ADDRESS, containerApiMock.Object, false); // Act & Assert Assert.DoesNotThrow(() => dockerRunspaceProvider.Kill(TEST_RUNSPACE_ID)); }