Пример #1
0
        /// <summary>
        /// Constructs a client with the specified storage and delivery classes.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="delivery"></param>
        /// <param name="breadcrumbs"></param>
        /// <param name="sessionTracking"></param>
        public Client(IConfiguration configuration, IDelivery delivery, IBreadcrumbs breadcrumbs, ISessionTracker sessionTracking)
        {
            _configuration   = configuration;
            _delivery        = delivery;
            _breadcrumbs     = breadcrumbs;
            _sessionTracking = sessionTracking;
            _middleware      = new List <Middleware>();

            UnhandledException.Instance.ConfigureClient(this, configuration);
        }
        public void Initialize_NullSessionTracker_ThrowsArgumentNullExpection()
        {
            // Arrange
            var             webDriverConfig = Substitute.For <IWebDriverConfig>();
            ISessionTracker tracker         = null;

            // Act
            TestDelegate action = () => _defaultPerformer.Initialize(webDriverConfig, tracker);

            // Assert
            Assert.Throws <ArgumentNullException>(action);
        }
Пример #3
0
        /// <summary>
        /// Bad design, circular dependency :(
        /// </summary>
        /// <param name="dataStoreConnectionFactory"></param>
        public void Initialize(
            IDataStoreConnectionFactory dataStoreConnectionFactory,
            IAggregateRootRepository repository,
            ISessionTracker sessionTracker)
        {
            _dataStoreConnectionFactory = dataStoreConnectionFactory;
            _repository     = repository;
            _sessionTracker = sessionTracker;

            // Todo: Why did I load all prior sessions into memory here?
            //sessionTracker.Initialize();

            _initialized = true;
        }
        public ISessionPerformer Initialize(IWebDriverConfig webDriverConfig, ISessionTracker tracker)
        {
            if (webDriverConfig == null)
            {
                throw new ArgumentNullException(nameof(webDriverConfig));
            }

            if (_initialized)
            {
                throw new InvalidOperationException($"{nameof(SequentialSessionPerformer)} can be initialized only once.");
            }

            _webDriver = new Lazy <IWebDriver>(() => WebDriverFactory.CreateFromConfig(webDriverConfig));
            _tracker   = tracker ?? throw new ArgumentNullException(nameof(tracker));

            _initialized = true;
            return(this);
        }
 private void ApplyEnabledState(bool enabled)
 {
     lock (_serviceLock)
     {
         if (enabled && ChannelGroup != null && SessionTracker == null)
         {
             SessionTracker = CreateSessionTracker(ChannelGroup, Channel, ApplicationSettings);
             if (!ApplicationLifecycleHelper.Instance.IsSuspended)
             {
                 SessionTracker.Resume();
             }
             SubscribeToApplicationLifecycleEvents();
         }
         else if (!enabled)
         {
             UnsubscribeFromApplicationLifecycleEvents();
             SessionTracker = null;
         }
     }
 }
 private void ApplyEnabledState(bool enabled)
 {
     lock (_serviceLock)
     {
         if (enabled && ChannelGroup != null && SessionTracker == null)
         {
             SessionTracker = CreateSessionTracker(ChannelGroup, Channel);
             ApplicationLifecycleHelper.Enabled = true;
             if (_hasStarted)
             {
                 SessionTracker.Resume();
             }
         }
         else if (!enabled)
         {
             ApplicationLifecycleHelper.Enabled = false;
             SessionTracker?.ClearSessions();
             SessionTracker = null;
         }
     }
 }