public void VSRestoreSettingsUtilities_RestoreSource(string[] restoreSources, string[] expectedRestoreSources) { using (var mockBaseDirectory = TestDirectory.Create()) { //Set Up var spec = new PackageSpec(); spec.RestoreMetadata = new ProjectRestoreMetadata(); spec.RestoreMetadata.ProjectPath = @"C:\project\projectPath.csproj"; spec.RestoreMetadata.Sources = restoreSources.Select(e => new PackageSource(e)).ToList(); var settings = new Settings(mockBaseDirectory); //Act var actualSources = VSRestoreSettingsUtilities.GetSources(settings, spec); //Assert Assert.True( Enumerable.SequenceEqual(expectedRestoreSources.OrderBy(t => t), actualSources.Select(e => e.Source).OrderBy(t => t)), "expected: " + string.Join(",", expectedRestoreSources.ToArray()) + "\nactual: " + string.Join(",", actualSources.Select(e => e.Source).ToArray())); } }
public async Task VSSolutionRestoreService_VSRestoreSettingsUtilities_Integration(string restoreSources, string restoreAdditionalProjectSources, string expectedRestoreSources, string restoreFallbackFolders, string restoreAdditionalFallbackFolders, string expectedFallbackFolders) { var cps = NewCpsProject(@"{ }"); var pri = cps.Builder .WithTool("Foo.Test", "2.0.0") .WithTargetFrameworkInfo( new VsTargetFrameworkInfo( "netcoreapp2.0", Enumerable.Empty <IVsReferenceItem>(), Enumerable.Empty <IVsReferenceItem>(), new[] { new VsProjectProperty("RestoreSources", restoreSources), new VsProjectProperty("RestoreFallbackFolders", restoreFallbackFolders), new VsProjectProperty("RestoreAdditionalProjectSources", restoreAdditionalProjectSources), new VsProjectProperty("RestoreAdditionalProjectFallbackFolders", restoreAdditionalFallbackFolders) })) .Build(); var projectFullPath = cps.ProjectFullPath; // Act var actualRestoreSpec = await CaptureNominateResultAsync(projectFullPath, pri); // Assert SpecValidationUtility.ValidateDependencySpec(actualRestoreSpec); var actualProjectSpec = actualRestoreSpec.GetProjectSpec(projectFullPath); Assert.NotNull(actualProjectSpec); var specSources = VSRestoreSettingsUtilities.GetSources(NullSettings.Instance, actualProjectSpec).Select(e => e.Source); var expectedSources = MSBuildStringUtility.Split(expectedRestoreSources); Assert.True(Enumerable.SequenceEqual(expectedSources.OrderBy(t => t), specSources.OrderBy(t => t))); var specFallback = VSRestoreSettingsUtilities.GetFallbackFolders(NullSettings.Instance, actualProjectSpec); var expectedFallback = MSBuildStringUtility.Split(expectedFallbackFolders); Assert.True( Enumerable.SequenceEqual(expectedFallback.OrderBy(t => t), specFallback.OrderBy(t => t)), "expected: " + string.Join(",", expectedFallback.ToArray()) + "\nactual: " + string.Join(",", specFallback.ToArray())); }