public async Task Initilize(int parallelTasks) { _collection = new ModuleCollection(); ModelsRegistration.RegisterModules(_collection); PostModelsRegistration.RegisterModules(_collection); _collection.RegisterModule <EsentInstanceProvider, IEsentInstanceProvider>(new EsentInstanceProvider(true)); _collection.RegisterModule <PostModelStore, IBoardPostStore>(new PostModelStore("makaba", parallelTasks)); _collection.RegisterModule <MakabaBoardReferenceDtoParsers, INetworkDtoParsers>(); _collection.RegisterModule <MakabaBoardReferenceDtoParsers, INetworkDtoParsers>(); _collection.RegisterModule <YoutubeIdService, IYoutubeIdService>(); _collection.RegisterModule <MakabaLinkParser, IEngineLinkParser>(); _collection.RegisterModule <AgilityHtmlDocumentFactory, IHtmlDocumentFactory>(); _collection.RegisterModule <MakabaHtmlParser, IHtmlParser>(); _collection.RegisterModule <MakabaPostDtoParsers, INetworkDtoParsers>(); MakabaModelsRegistration.RegisterModules(_collection); TableVersionStatusForTests.ClearInstance(); await _collection.Seal(); _provider = _collection.GetModuleProvider(); var module = _provider.QueryModule(typeof(IBoardPostStore), "makaba") ?? throw new ModuleNotFoundException(); _store = module.QueryView <IBoardPostStore>() ?? throw new ModuleNotFoundException(); }
public async Task Initialize() { _collection = new ModuleCollection(); _collection.RegisterModule <MakabaNetworkConfig, IMakabaNetworkConfig>(); _collection.RegisterModule <CommonUriGetter, INetworkUriGetter>(); _collection.RegisterModule <MakabaUriGetter, INetworkUriGetter>(); await _collection.Seal(); _provider = _collection.GetModuleProvider(); }
public async Task Initialize() { _collection = new ModuleCollection(); _collection.RegisterModule <ObjectSerializationService, IObjectSerializationService>(); PostModelsRegistration.RegisterModules(_collection); LinkModelsRegistration.RegisterModules(_collection); _collection.RegisterModule <FakeExternalPostMediaSerializer, IObjectSerializer>(); _collection.RegisterModule <FakePostAttributeSerializer, IObjectSerializer>(); _collection.RegisterModule <FakePostNodeSerializer, IObjectSerializer>(); await _collection.Seal(); _modules = _collection.GetModuleProvider(); }
public async Task Initialize() { _collection = new ModuleCollection(); LinkModelsRegistration.RegisterModules(_collection); CommonSerializationRegistration.RegisterModules(_collection); _collection.RegisterModule <EsentInstanceProvider, IEsentInstanceProvider>(new EsentInstanceProvider(true)); _collection.RegisterModule <BlobsModelStore, IBlobsModelStore>(); _collection.RegisterModule <MakabaBoardReferenceDtoParsers, INetworkDtoParsers>(); TableVersionStatusForTests.ClearInstance(); await _collection.Seal(); _provider = _collection.GetModuleProvider(); var module = _provider.QueryModule <object>(typeof(IBlobsModelStore), null) ?? throw new ModuleNotFoundException(); _store = module.QueryView <IBlobsModelStore>() ?? throw new ModuleNotFoundException(); }
public async Task MakabaNetworkConfig() { var config = _provider.QueryModule <IMakabaNetworkConfig>(); Assert.AreEqual(new Uri("https://2ch.hk/"), config.BaseUri, "Значение по умолчанию не совпадает"); config.BaseUri = new Uri("http://2ch.so/"); await config.Save(); await _collection.Dispose(); _collection = new ModuleCollection(); _collection.RegisterModule <MakabaNetworkConfig, IMakabaNetworkConfig>(); _collection.RegisterModule <CommonUriGetter, INetworkUriGetter>(); _collection.RegisterModule <MakabaUriGetter, INetworkUriGetter>(); await _collection.Seal(); _provider = _collection.GetModuleProvider(); Assert.AreEqual(new Uri("http://2ch.so/"), config.BaseUri, "Значение не совпадает"); }
public async Task TestSuspend() { var collection = new ModuleCollection(); var modules = new SuspensionAwareModule[] { new SuspensionAwareModule(true), new SuspensionAwareModule(true), new SuspensionAwareModule(true), new SuspensionAwareModule(true), }; foreach (var m in modules) { var lt = m.QueryView <IModuleLifetime>(); Assert.IsNotNull(lt, "Модуль должен поддерживать управление временем жизни"); Assert.IsTrue(lt.IsSuspendAware, "Модуль должен поддерживать приостановку работы"); } foreach (var m in modules) { collection.RegisterModule <SuspensionAwareModule, ISuspensionAwareModule>(m); } await collection.Seal(); foreach (var m in modules) { Assert.IsFalse(m.IsSuspended, "Модуль не должен быть приостановлен"); } await collection.Suspend(); foreach (var m in modules) { Assert.IsTrue(m.IsSuspended, "Модуль должен быть приостановлен"); } await collection.Resume(); foreach (var m in modules) { Assert.IsFalse(m.IsSuspended, "Модуль не должен быть приостановлен после Resume"); Assert.IsTrue(m.IsAllResumed, "Должен быть вызван метод AllResumed()"); Assert.AreEqual(1, m.AllResumedCount, "Метод AllResumed() должен быть вызван один раз"); } await collection.Dispose(); }