public static ExternalModuleCatalog GetCatalog(IOptions <ExternalModuleCatalogOptions> options, LocalStorageModuleCatalog localCatalog) { if (_catalog == null) { var client = new ExternalModulesClient(options); var logger = new LoggerFactory().CreateLogger <ExternalModuleCatalog>(); _catalog = new ExternalModuleCatalog(localCatalog, client, options, logger); _catalog.Load(); } else { _catalog.Reload(); } return(_catalog); }
private static ExternalModuleCatalog CreateExternalModuleCatalog(ExternalModuleManifest[] manifests) { var localModulesCatalog = new Moq.Mock <ILocalModuleCatalog>(); localModulesCatalog.Setup(x => x.Modules).Returns(new List <ManifestModuleInfo>()); var json = JsonConvert.SerializeObject(manifests); var client = new Moq.Mock <IExternalModulesClient>(); client.Setup(x => x.OpenRead(Moq.It.IsAny <Uri>())).Returns(new MemoryStream(Encoding.UTF8.GetBytes(json ?? ""))); var logger = new Moq.Mock <ILogger <ExternalModuleCatalog> >(); var options = Options.Create(new ExternalModuleCatalogOptions()); var result = new ExternalModuleCatalog(localModulesCatalog.Object, client.Object, options, logger.Object); return(result); }
public static ExternalModuleCatalog GetCatalog(IOptions <ExternalModuleCatalogOptions> options, LocalStorageModuleCatalog localCatalog) { if (_catalog == null) { var platformRelease = GithubManager.GetPlatformRelease(null).GetAwaiter().GetResult(); PlatformVersion.CurrentVersion = new SemanticVersion(Version.Parse(platformRelease.TagName)); // workaround to see all modules in the external catalog var client = new ExternalModulesClient(options); var logger = new LoggerFactory().CreateLogger <ExternalModuleCatalog>(); _catalog = new ExternalModuleCatalog(localCatalog, client, options, logger); _catalog.Load(); } else { _catalog.Reload(); } return(_catalog); }
private IExternalModuleCatalog GetExternalModuleCatalog(ModuleManifest[] installedModuleManifests) { var installedModules = GetManifestModuleInfos(installedModuleManifests).Select(x => { x.IsInstalled = true; return(x); }).ToList(); var localCatalogModulesMock = new Mock <ILocalModuleCatalog>(); localCatalogModulesMock.Setup(x => x.Modules).Returns(installedModules); var externalModulesClientMock = new Mock <IExternalModulesClient>(); var options = Options.Create(new Mock <ExternalModuleCatalogOptions>().Object); var loggerMock = new Mock <ILogger <ExternalModuleCatalog> >(); var externalModuleCatalog = new ExternalModuleCatalog(localCatalogModulesMock.Object, externalModulesClientMock.Object, options, loggerMock.Object); foreach (var module in installedModules) { externalModuleCatalog.AddModule(module); } return(externalModuleCatalog); }
private static ExternalModuleCatalog CreateExternalModuleCatalog(ExternalModuleManifest[] manifests, bool includePrerelease = false) { var localModulesCatalog = new Moq.Mock <ILocalModuleCatalog>(); localModulesCatalog.Setup(x => x.Modules).Returns(GetManifestModuleInfos(new[] { new ModuleManifest { Id = "B", Version = "1.3.0", PlatformVersion = "3.0.0" } })); var json = JsonConvert.SerializeObject(manifests); var client = new Moq.Mock <IExternalModulesClient>(); client.Setup(x => x.OpenRead(Moq.It.IsAny <Uri>())).Returns(new MemoryStream(Encoding.UTF8.GetBytes(json ?? ""))); var logger = new Moq.Mock <ILogger <ExternalModuleCatalog> >(); var options = Options.Create(new ExternalModuleCatalogOptions() { ModulesManifestUrl = new Uri("http://nowhere.mock"), IncludePrerelease = includePrerelease }); var result = new ExternalModuleCatalog(localModulesCatalog.Object, client.Object, options, logger.Object); return(result); }