public void Initialize(bool shutdown) { Context.Set <IDetectableManager>(new DetectableManager()); Context.Set(Settings); CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(Context.Get <AllSettings>().SelectedCulture); CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.DefaultThreadCurrentCulture; Context.Set <IProxyClientSearcher>(new ProxyClientSearcher()); Context.Set <IUsedProxies>(new ProxyStorage(ReadProxyList(Constants.UsedProxiesStorage.Location))); ProxyStorage blacklist = new ProxyStorage(ReadProxyList(Constants.BlackListStorage.Location)); Context.Set <IBlackList>(blacklist); Context.Set <IBlackListManager>(blacklist); Context.Set <IVersionProvider>(new VersionProvider()); if (!shutdown) { new VersionManager().Check(); } Context.Get <IGA>().TrackEventAsync(EventType.Program, Resources.Started); Context.Get <IGA>().TrackPageViewAsync(typeof(SearchControl).Name); Context.Set <ITaskManager>(new TaskManager()); Context.Set <IRatingManager>(new RatingManager()); }
public void TestRemoveOneProxy() { var storage = new ProxyStorage(_endPoint.Object, _channel.Object, _codeGenerator.Object); var proxy = storage.CreateProxy <IByReferenceType>(1234); proxy.Should().NotBeNull(); storage.GetProxy <IByReferenceType>(1234).Should().BeSameAs(proxy); storage.GetExistingOrCreateNewProxy <IByReferenceType>(1234).Should().BeSameAs(proxy); IProxy actualProxy; int unused; storage.TryGetProxy(1234, out actualProxy, out unused); actualProxy.Should().BeSameAs(proxy); storage.RemoveProxiesInRange(1234, 1234); new Action(() => storage.GetProxy <IByReferenceType>(1234)).ShouldThrow <ArgumentException>(); var newProxy = storage.GetExistingOrCreateNewProxy <IByReferenceType>(1234); newProxy.Should().NotBeNull(); newProxy.Should().NotBeSameAs(proxy); storage.TryGetProxy(1234, out actualProxy, out unused); actualProxy.Should().BeSameAs(newProxy); }
public void LoadingCollectionsTest() { var ps = new ProxyStorage(); ps.Init(); var ovds = ProxyStorage.OVDCollection; var pcs = ProxyStorage.PCInfoCollection; Assert.IsTrue(ProxyStorage.PCInfoCollection.Count > 0 && ProxyStorage.OVDCollection.Count > 0); }
public void TestRemoveSeveralProxies() { var storage = new ProxyStorage(_endPoint.Object, _channel.Object, _codeGenerator.Object); var proxies = Enumerable.Range(1000, 100).Select(i => storage.CreateProxy <IByReferenceType>((ulong)i)) .ToList(); for (int i = 0; i < 100; ++i) { var objectId = (ulong)(1000 + i); storage.GetProxy <IByReferenceType>(objectId).Should().BeSameAs(proxies[i]); } storage.RemoveProxiesInRange(1042, 1058); for (int i = 0; i < 42; ++i) { var objectId = (ulong)(1000 + i); storage.GetProxy <IByReferenceType>(objectId).Should().BeSameAs(proxies[i]); } for (int i = 43; i < 59; ++i) { var objectId = (ulong)(1000 + i); new Action(() => storage.GetProxy <IByReferenceType>(objectId)).ShouldThrow <ArgumentException>(); IProxy proxy; int numProxies; storage.TryGetProxy(objectId, out proxy, out numProxies); proxy.Should().BeNull(); } for (int i = 59; i < 100; ++i) { var objectId = (ulong)(1000 + i); storage.GetProxy <IByReferenceType>(objectId).Should().BeSameAs(proxies[i]); } }