public void SourceControlMapping_Resolver_Success() { // Arrange: DependencyResolverFactory.RegisterResolverType(new SourceControlMappingResolverType()); // Mock logger: Mock <ILogger> logger = new Mock <ILogger>(); logger.Setup(f => f.LogMsg(It.IsAny <string>())); logger.Setup(f => f.ShowMessages()); // Mock dependency graph: DependencyGraphCreator target = new DependencyGraphCreator("Data", logger.Object, true); Mock <ISettings <ServiceValidSettings> > service = new Mock <ISettings <ServiceValidSettings> >(); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultTeamProjectCollection)).Returns(Values.TeamProjectCollection); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultWorkspaceName)).Returns(_workspaceName); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultWorkspaceOwner)).Returns(Values.WorkspaceOwner); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultOutputBaseFolder)).Returns(_localWorkspaceFolder); service.Setup(f => f.GetSetting(ServiceValidSettings.BinaryTeamProjectCollectionUrl)).Returns(Values.TeamProjectCollection); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultRelativeOutputPath)).Returns(@"..\Bin"); service.Setup(f => f.GetSetting(ServiceValidSettings.BinaryRepositoryTeamProject)).Returns(""); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultDependencyDefinitionFilename)).Returns("component.targets"); // Act: var result = target.GetDependencyGraph(service.Object, Path.Combine(_localWorkspaceFolder, @"SourceControlTarget\component.targets")); var dependencyService = new DependencyService(service.Object); dependencyService.DownloadGraph(result, logger.Object, true, true); // Assert: var dllFiles = Directory.GetFiles(_localWorkspaceFolder + @"..\..\DependencySource", "*.dll").Select(path => Path.GetFileName(path)).ToArray(); Assert.AreEqual("helloWorld.dll", dllFiles.First()); }
public void VNextBuildResult_Resolver_Success() { // Arrange: DependencyResolverFactory.RegisterResolverType(new VNextBuildResultResolverType()); // Mock logger: Mock <ILogger> logger = new Mock <ILogger>(); logger.Setup(f => f.LogMsg(It.IsAny <string>())); logger.Setup(f => f.ShowMessages()); // Mock dependency graph: DependencyGraphCreator target = new DependencyGraphCreator("Data", logger.Object, true); Mock <ISettings <ServiceValidSettings> > service = new Mock <ISettings <ServiceValidSettings> >(); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultTeamProjectCollection)).Returns(Values.TeamProjectCollection); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultWorkspaceName)).Returns(Values.WorkSpaceName); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultWorkspaceOwner)).Returns(Values.WorkspaceOwner); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultOutputBaseFolder)).Returns(Values.PathToTeamProject); service.Setup(f => f.GetSetting(ServiceValidSettings.BinaryTeamProjectCollectionUrl)).Returns(Values.TeamProjectCollection); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultRelativeOutputPath)).Returns(@"..\Bin"); service.Setup(f => f.GetSetting(ServiceValidSettings.BinaryRepositoryTeamProject)).Returns(""); service.Setup(f => f.GetSetting(ServiceValidSettings.DefaultDependencyDefinitionFilename)).Returns("component.targets"); // Act: var result = target.GetDependencyGraph(service.Object, Values.PathToTeamProject + @"\VNextBuildResult\component.targets"); var dependencyService = new DependencyService(service.Object); dependencyService.DownloadGraph(result, logger.Object, true, true); // Assert: var dllFiles = Directory.GetFiles(Values.DependencyOutputPath, "*").Select(path => Path.GetFileName(path)).ToArray(); Assert.AreEqual("AssemblyInfo.cs", dllFiles.First()); }
/// <summary> /// Creates a dependency graph. /// </summary> /// <param name="path">Local Path to component.targets file with filename</param> /// <param name="log">Logger to log messages to</param> public IGraph GetDependencyGraph(string path, ILogger log) { if (!File.Exists(path)) { throw new FileNotFoundException("Local file could not be found.", path); } //var creator = new DependencyGraphCreator(Path.GetFileName(path), log, true, new TfsWorkspaceInfo()); var creator = new DependencyGraphCreator(Path.GetFileName(path), log, true); return(creator.GetDependencyGraph(_settings, path)); }