public async Task GetImageBuildsProjectFromFile() { var file = ProjectLocator.GetCurrentDir().Parent?.Parent?.Parent?.Parent ?.GetFiles("ExampleProject.csproj", SearchOption.AllDirectories).Single(); var imageSource = new DockerfileImageProvider(file); string tag = await imageSource.GetImage(null); var image = await new DockerClientProvider().GetDockerClient().Images .ListImagesAsync(new ImagesListParameters { MatchName = tag }); Assert.Single(image); }
public void GetProjectsInSln_ReturnsDockerizedProjects() { var slnPath = ProjectLocator.GetCurrentDir().Parent?.Parent?.Parent?.Parent?.GetFiles("*.sln").SingleOrDefault()?.FullName; if (slnPath == null) { throw new FileNotFoundException("Can't find sln file"); } var locator = new ProjectLocator(); var dockerizedProjects = locator.GetProjectNamesFromSln(slnPath).ToArray(); var exampleProj = dockerizedProjects.SingleOrDefault(p => p.names.Contains(nameof(ExampleProject))); Assert.True(File.Exists(exampleProj.path)); Assert.Contains("ExampleProjectAsm", exampleProj.names); Assert.Contains("ExampleProjectNs", exampleProj.names); var allProjects = locator.GetProjectNamesFromSln(slnPath, _ => true).ToArray(); Assert.True(allProjects.Length > dockerizedProjects.Length); }
public async Task GetImageBuildsProjectFromNames() { string name = "foo"; var file = ProjectLocator.GetCurrentDir().Parent?.Parent?.Parent?.Parent ?.GetFiles("ExampleProject.csproj", SearchOption.AllDirectories).Single(); var projectLocator = new Mock <IProjectLocator>(); projectLocator.Setup(p => p.GetDockerProject(name)).Returns(file); var imageSource = new DockerfileImageProvider(name, projectLocator.Object); string tag = await imageSource.GetImage(null); var image = await new DockerClientProvider().GetDockerClient().Images .ListImagesAsync(new ImagesListParameters { MatchName = tag }); Assert.Single(image); }