public async Task AnalyzeTest() { var dependencyResult = Enumerable.Range(0, 10).ToDictionary( o => new MemberInfo { MemberDocId = "type" + o }, o => Enumerable.Range(0, o).Select(count => new AssemblyInfo { AssemblyIdentity = "dependency" + count }).ToList() as ICollection <AssemblyInfo>); var expectedResult = Enumerable.Range(0, 10).Select(o => Tuple.Create("type" + o, o)).ToList(); var apiPortService = Substitute.For <IApiPortService>(); apiPortService.SendAnalysisAsync(Arg.Any <AnalyzeRequest>()).Returns(r => { var a = r.Arg <AnalyzeRequest>(); var foundDocIds = a.Dependencies.Select(o => Tuple.Create(o.Key.MemberDocId, o.Value.Count)).ToList(); Assert.Equal <IEnumerable <Tuple <string, int> > >(expectedResult.OrderBy(k => k.Item1), foundDocIds.OrderBy(k => k.Item1)); return(CreateResponse(new AnalyzeResponse())); }); var progressReporter = Substitute.For <IProgressReporter>(); var targetMapper = Substitute.For <ITargetMapper>(); var reportGenerator = Substitute.For <IReportGenerator>(); var writer = Substitute.For <IFileWriter>(); var dependencyFinder = Substitute.For <IDependencyFinder>(); dependencyFinder.FindDependencies(Arg.Any <IEnumerable <FileInfo> >(), Arg.Any <IProgressReporter>()).Returns(r => { var list = r.Arg <IEnumerable <FileInfo> >(); var shared = r.Arg <IProgressReporter>(); var dependencies = Substitute.For <IDependencyInfo>(); dependencies.Dependencies.Returns(dependencyResult); dependencies.UnresolvedAssemblies.Returns(new Dictionary <string, ICollection <string> >()); dependencies.UserAssemblies.Returns(Enumerable.Empty <AssemblyInfo>()); dependencies.AssembliesWithErrors.Returns(Enumerable.Empty <string>()); return(dependencies); }); var ignoreAssemblyInfoList = Substitute.For <IEnumerable <IgnoreAssemblyInfo> >(); var client = new ApiPortClient(apiPortService, progressReporter, targetMapper, dependencyFinder, reportGenerator, ignoreAssemblyInfoList, writer); var options = Substitute.For <IApiPortOptions>(); options.Targets.Returns(Enumerable.Empty <string>()); options.InputAssemblies.Returns(Enumerable.Empty <FileInfo>()); var result = await client.AnalyzeAssembliesAsync(options); }
public static async Task AnalyzeAssemblies_DoesNotThrowsOnInvalidOptions_TargetCount() { var service = Substitute.For <IApiPortService>(); var progressReporter = Substitute.For <IProgressReporter>(); var targetMapper = Substitute.For <ITargetMapper>(); var dependencyFinder = Substitute.For <IDependencyFinder>(); var reportGenerator = Substitute.For <IReportGenerator>(); var ignoreAssemblyInfoList = Substitute.For <IEnumerable <IgnoreAssemblyInfo> >(); var writer = Substitute.For <IFileWriter>(); var client = new ApiPortClient(service, progressReporter, targetMapper, dependencyFinder, reportGenerator, ignoreAssemblyInfoList, writer); var options = Substitute.For <IApiPortOptions>(); options.Targets.Returns(Enumerable.Range(0, 16).Select(x => x.ToString(CultureInfo.CurrentCulture))); options.OutputFormats.Returns(new[] { "HTML" }); var item = await client.AnalyzeAssembliesAsync(options); }