public async Task ShouldGetDependencies() { //Arrange var name = "msgraph-training-aspnetmvcapp"; var packageManager = "NUGET"; //Act var repository = await _repositoriesService.GetRepository(name); var res = repository.DependencyGraphManifests.Nodes.SelectMany(n => n.Dependencies.Nodes.Select(n => n.packageManager)).ToList(); var library = repository.DependencyGraphManifests.Nodes.SelectMany(n => n.Dependencies.Nodes.Select(n => n.packageName)).Contains("Microsoft.Graph"); //Assert Assert.NotNull(repository); Assert.True(library); Assert.Equal(packageManager, res.FirstOrDefault()); Assert.IsType <Repository>(repository); }
public async Task <IActionResult> GetRepositoriesAsync(string id) { if (!_cache.TryGetValue(id, out Repository repository)) { repository = await _repositoriesService.GetRepository(id); var cacheEntryOptions = new MemoryCacheEntryOptions().SetAbsoluteExpiration(TimeSpan.FromSeconds(_config.GetValue <double>(Constants.Timeout))); _cache.Set(id, repository, cacheEntryOptions); _logger.LogInformation($"RepositoriesController : {id} : repositories cache refreshed"); } return(Ok(repository)); }
/// <summary> /// Sets up HTTP methods mappings. /// </summary> /// <param name="service">Service handling requests</param> public RepositoriesModule(RepositoriesService service) : base("/") { Get["/api/program/{programId}/repositories"] = parameters => { var programId = Parameters.ValueOf <string>(parameters, Context.Request, "programId", ParameterType.Path); var xGwImsOrgId = Parameters.ValueOf <string>(parameters, Context.Request, "xGwImsOrgId", ParameterType.Header); var authorization = Parameters.ValueOf <string>(parameters, Context.Request, "authorization", ParameterType.Header); var xApiKey = Parameters.ValueOf <string>(parameters, Context.Request, "xApiKey", ParameterType.Header); Preconditions.IsNotNull(programId, "Required parameter: 'programId' is missing at 'GetRepositories'"); Preconditions.IsNotNull(xGwImsOrgId, "Required parameter: 'xGwImsOrgId' is missing at 'GetRepositories'"); Preconditions.IsNotNull(authorization, "Required parameter: 'authorization' is missing at 'GetRepositories'"); Preconditions.IsNotNull(xApiKey, "Required parameter: 'xApiKey' is missing at 'GetRepositories'"); return(service.GetRepositories(Context, programId, xGwImsOrgId, authorization, xApiKey)); }; Get["/api/program/{programId}/repository/{repositoryId}"] = parameters => { var programId = Parameters.ValueOf <string>(parameters, Context.Request, "programId", ParameterType.Path); var repositoryId = Parameters.ValueOf <string>(parameters, Context.Request, "repositoryId", ParameterType.Path); var xGwImsOrgId = Parameters.ValueOf <string>(parameters, Context.Request, "xGwImsOrgId", ParameterType.Header); var authorization = Parameters.ValueOf <string>(parameters, Context.Request, "authorization", ParameterType.Header); var xApiKey = Parameters.ValueOf <string>(parameters, Context.Request, "xApiKey", ParameterType.Header); Preconditions.IsNotNull(programId, "Required parameter: 'programId' is missing at 'GetRepository'"); Preconditions.IsNotNull(repositoryId, "Required parameter: 'repositoryId' is missing at 'GetRepository'"); Preconditions.IsNotNull(xGwImsOrgId, "Required parameter: 'xGwImsOrgId' is missing at 'GetRepository'"); Preconditions.IsNotNull(authorization, "Required parameter: 'authorization' is missing at 'GetRepository'"); Preconditions.IsNotNull(xApiKey, "Required parameter: 'xApiKey' is missing at 'GetRepository'"); return(service.GetRepository(Context, programId, repositoryId, xGwImsOrgId, authorization, xApiKey)); }; }