private ApiInfoStorage[] GetApis() { var targets11 = new[] { Windows80, NetCore50, Net11 }; var targets40 = new[] { Windows80, NetCore50, Net40 }; var apis = new[] { new ApiInfoStorage { DocId = "N:System.Collections", FullName = "System.Collections", Name = "System.Collections", Type = "", Parent = null, Targets = targets11 }, new ApiInfoStorage { DocId = "N:System.Collections.Concurrent", FullName = "System.Collections.Concurrent", Name = "System.Collections.Concurrent", Type = "", Parent = null, Targets = targets40 }, new ApiInfoStorage { DocId = "T:System.Collections.Concurrent.ConcurrentBag`1", FullName = "System.Collections.Concurrent.ConcurrentBag<T>", Name = "ConcurrentBag<T>", Type = "", Parent = "N:System.Collections.Concurrent", Targets = targets40 }, new ApiInfoStorage { DocId = "P:System.Collections.Concurrent.ConcurrentBag`1.Count", FullName = "System.Collections.Concurrent.ConcurrentBag<T>.Count", Name = "Count", Type = "Int32", Parent = "T:System.Collections.Concurrent.ConcurrentBag`1", Targets = targets40 }, new ApiInfoStorage { DocId = "M:System.Collections.Concurrent.ConcurrentBag`1.CopyTo(`0[],System.Int32)", FullName = "System.Collections.Concurrent.ConcurrentBag<T>.CopyTo(T[], Int32)", Name = "CopyTo(T[], Int32)", Type = "Void", Parent = "T:System.Collections.Concurrent.ConcurrentBag`1", Targets = targets40 }, new ApiInfoStorage { DocId = "M:System.Collections.Concurrent.ConcurrentBag`1.get_Count", FullName = "System.Collections.Concurrent.ConcurrentBag<T>.Count.get_Count()", Name = "get_Count()", Type = "Int32", Parent = "P:System.Collections.Concurrent.ConcurrentBag`1.Count", Targets = targets40 } }; return apis; }
public void ToStringWithExpandedTargets() { const string group = "name"; const string expanded1 = "expanded1"; const string expanded2 = "expanded2"; var expandedTargets = new[] { expanded1, expanded2 }; var info = new TargetInformation { Name = group, ExpandedTargets = expandedTargets }; var groupedToString = String.Format(LocalizedStrings.TargetInformationGroups, group, String.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator + " ", expandedTargets)); Assert.Equal(groupedToString, info.ToString()); }
public void GetRecommendedChange_DoesNotExist() { var docId = "Property:Foo"; var ancestors = new[] { "Class:Test", "Namespace:MyTestNamespace" }; var catalog = Substitute.For<IApiCatalogLookup>(); var recommendations = AncestorApiRecommendations.Create(catalog); catalog.GetAncestors(docId).Returns(ancestors); var actual = recommendations.GetRecommendedChanges(docId); Assert.Equal(DefaultRecommendedAction, actual); catalog.Received(1).GetAncestors(docId); }
public void GetRecommendedChange_Parent() { var docId = "Property:Foo"; var matchingParentDocId = "Class:Test"; var ancestors = new[] { matchingParentDocId, "Namespace:MyTestNamespace" }; var expectedAction = "This is the recommended action for Class:Test"; var catalog = Substitute.For<IApiCatalogLookup>(); var recommendations = AncestorApiRecommendations.Create(catalog); catalog.GetAncestors(docId).Returns(ancestors); catalog.GetRecommendedChange(matchingParentDocId).Returns(expectedAction); var actual = recommendations.GetRecommendedChanges(docId); Assert.Equal(expectedAction, actual); catalog.Received(1).GetAncestors(docId); }
public void GetRecommendedChange_FirstMatchingRecommendation() { var recommendedChanges = new[] { new { DocId = "Property:Foo", Change = "This is the first recommendation!" }, new { DocId = "Class:FooTest", Change = "This is the second recommendation!" }, new { DocId = "Namespace:MyTestNamespace", Change = "This is the 3rd recommendation!" } }; var expected = recommendedChanges[0]; var ancestors = recommendedChanges.Select(r => r.DocId).ToArray(); var catalog = Substitute.For<IApiCatalogLookup>(); var recommendations = AncestorApiRecommendations.Create(catalog); catalog.GetAncestors(expected.DocId).Returns(ancestors); foreach (var item in recommendedChanges) { catalog.GetRecommendedChange(item.DocId).Returns(item.Change); } var actual = recommendations.GetRecommendedChanges(expected.DocId); Assert.Equal(expected.Change, actual); }
public void GetBreakingChange_Parent() { var docId = "Property:Foo"; var matchingParentDocId = "Class:Test"; var ancestors = new[] { matchingParentDocId, "Namespace:MyTestNamespace" }; var expected = new[] { new BreakingChange { Id = "5" }, new BreakingChange { Id = "7" } }; var breakingChanges = new Dictionary<string, IEnumerable<BreakingChange>>(StringComparer.Ordinal) { { docId, null }, { matchingParentDocId, expected } }; var catalog = Substitute.For<IApiCatalogLookup>(); var recommendations = BreakingChangeRecommendationsMock.Create(catalog, breakingChanges); catalog.GetAncestors(docId).Returns(ancestors); var actual = recommendations.GetBreakingChanges(docId); Assert.Equal(expected, actual); catalog.Received(1).GetAncestors(docId); }