Exemplo n.º 1
0
        /// <summary>
        /// Initialize mock objects.
        /// </summary>
        public PoolTests()
        {
            _jobManagerFactory = Substitute.For<IJobManagerFactory>();
            _jobTrackerFactory = Substitute.For<IJobTrackerFactory>();
            _hashAlgorithmFactory = Substitute.For<IHashAlgorithmFactory>();
            _shareManagerFactory = Substitute.For<IShareManagerFactory>();
            _minerManagerFactory = Substitute.For<IMinerManagerFactory>();
            _serverFactory = Substitute.For<IServerFactory>();
            _serviceFactory = Substitute.For<IServiceFactory>();
            _storageManagerFactory = Substitute.For<IStorageFactory>();
            _globalConfigFactory = Substitute.For<IGlobalConfigFactory>();

            _daemonClient = Substitute.For<IDaemonClient>();
            _minerManager = Substitute.For<IMinerManager>();
            _jobManager = Substitute.For<IJobManager>();
            _jobTracker = Substitute.For<IJobTracker>();
            _shareManager = Substitute.For<IShareManager>();
            _miningServer = Substitute.For<IMiningServer>();
            _rpcService = Substitute.For<IRpcService>();
            _storage = Substitute.For<IStorage>();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Pool" /> class.
        /// </summary>
        /// <param name="hashAlgorithmFactory">The hash algorithm factory.</param>
        /// <param name="serverFactory">The server factory.</param>
        /// <param name="serviceFactory">The service factory.</param>
        /// <param name="client">The client.</param>
        /// <param name="minerManagerFactory">The miner manager factory.</param>
        /// <param name="jobTrackerFactory"></param>
        /// <param name="jobManagerFactory">The job manager factory.</param>
        /// <param name="shareManagerFactory">The share manager factory.</param>
        /// <param name="storageManagerFactory"></param>
        /// <param name="globalConfigFactory"></param>
        public Pool(
            IHashAlgorithmFactory hashAlgorithmFactory, 
            IServerFactory serverFactory, 
            IServiceFactory serviceFactory,
            IDaemonClient client, 
            IMinerManagerFactory minerManagerFactory, 
            IJobTrackerFactory jobTrackerFactory,
            IJobManagerFactory jobManagerFactory, 
            IShareManagerFactory shareManagerFactory,
            IStorageFactory storageManagerFactory,
            IGlobalConfigFactory globalConfigFactory)
        {
            Enforce.ArgumentNotNull(hashAlgorithmFactory, "IHashAlgorithmFactory");
            Enforce.ArgumentNotNull(serverFactory, "IServerFactory");
            Enforce.ArgumentNotNull(serviceFactory, "IServiceFactory");
            Enforce.ArgumentNotNull(client, "IDaemonClient");
            Enforce.ArgumentNotNull(minerManagerFactory, "IMinerManagerFactory");
            Enforce.ArgumentNotNull(jobTrackerFactory, "IJobTrackerFactory");
            Enforce.ArgumentNotNull(jobManagerFactory, "IJobManagerFactory");
            Enforce.ArgumentNotNull(shareManagerFactory, "IShareManagerFactory");
            Enforce.ArgumentNotNull(storageManagerFactory, "IStorageFactory");
            Enforce.ArgumentNotNull(globalConfigFactory, "IGlobalConfigFactory");

            _daemonClient = client;
            _minerManagerFactory = minerManagerFactory;
            _jobManagerFactory = jobManagerFactory;
            _jobTrackerFactory = jobTrackerFactory;
            _shareManagerFactory = shareManagerFactory;
            _serverFactory = serverFactory;
            _serviceFactory = serviceFactory;
            _hashAlgorithmFactory = hashAlgorithmFactory;
            _storageManagerFactory = storageManagerFactory;
            _globalConfigFactory = globalConfigFactory;

            GenerateInstanceId();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Instantiates a new instance of <see cref="AzureCommandBusReceiver{TAuthenticationToken}"/>.
 /// </summary>
 public AzureCommandBusReceiver(IConfigurationManager configurationManager, IMessageSerialiser <TAuthenticationToken> messageSerialiser, IAuthenticationTokenHelper <TAuthenticationToken> authenticationTokenHelper, ICorrelationIdHelper correlationIdHelper, ILogger logger, IAzureBusHelper <TAuthenticationToken> azureBusHelper, IBusHelper busHelper, IHashAlgorithmFactory hashAlgorithmFactory)
     : base(configurationManager, messageSerialiser, authenticationTokenHelper, correlationIdHelper, logger, azureBusHelper, busHelper, hashAlgorithmFactory, false)
 {
     TelemetryHelper = configurationManager.CreateTelemetryHelper("Cqrs.Azure.CommandBus.Receiver.UseApplicationInsightTelemetryHelper", correlationIdHelper);
     FilterKey       = new Dictionary <string, string>();
 }
 /// <summary>
 /// Instantiates a new instance of <see cref="AzureQueuedEventBusReceiver{TAuthenticationToken}"/>.
 /// </summary>
 public AzureQueuedEventBusReceiver(IConfigurationManager configurationManager, IMessageSerialiser <TAuthenticationToken> messageSerialiser, IAuthenticationTokenHelper <TAuthenticationToken> authenticationTokenHelper, ICorrelationIdHelper correlationIdHelper, ILogger logger, IAzureBusHelper <TAuthenticationToken> azureBusHelper, IBusHelper busHelper, IHashAlgorithmFactory hashAlgorithmFactory)
     : base(configurationManager, messageSerialiser, authenticationTokenHelper, correlationIdHelper, logger, azureBusHelper, busHelper, hashAlgorithmFactory)
 {
     QueueTracker     = new ConcurrentDictionary <string, ConcurrentQueue <IEvent <TAuthenticationToken> > >();
     QueueTrackerLock = new ReaderWriterLockSlim();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Instantiates a new instance of <see cref="AzureEventBusReceiver{TAuthenticationToken}"/>.
 /// </summary>
 public AzureEventBusReceiver(IConfigurationManager configurationManager, IMessageSerialiser <TAuthenticationToken> messageSerialiser, IAuthenticationTokenHelper <TAuthenticationToken> authenticationTokenHelper, ICorrelationIdHelper correlationIdHelper, ILogger logger, IHashAlgorithmFactory hashAlgorithmFactory, IAzureBusHelper <TAuthenticationToken> azureBusHelper)
     : base(configurationManager, messageSerialiser, authenticationTokenHelper, correlationIdHelper, logger, hashAlgorithmFactory, azureBusHelper, false)
 {
     TelemetryHelper = configurationManager.CreateTelemetryHelper("Cqrs.Azure.EventHub.EventBus.Receiver.UseApplicationInsightTelemetryHelper", correlationIdHelper);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Instantiate a new instance of <see cref="AzureCommandBus{TAuthenticationToken}"/>.
 /// </summary>
 protected AzureCommandBus(IConfigurationManager configurationManager, IMessageSerialiser <TAuthenticationToken> messageSerialiser, IAuthenticationTokenHelper <TAuthenticationToken> authenticationTokenHelper, ICorrelationIdHelper correlationIdHelper, ILogger logger, IHashAlgorithmFactory hashAlgorithmFactory, IAzureBusHelper <TAuthenticationToken> azureBusHelper, bool isAPublisher)
     : base(configurationManager, messageSerialiser, authenticationTokenHelper, correlationIdHelper, logger, hashAlgorithmFactory, isAPublisher)
 {
     AzureBusHelper = azureBusHelper;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Instantiates a new instance of <see cref="AzureServiceBus{TAuthenticationToken}"/>
        /// </summary>
        protected AzureServiceBus(IConfigurationManager configurationManager, IMessageSerialiser <TAuthenticationToken> messageSerialiser, IAuthenticationTokenHelper <TAuthenticationToken> authenticationTokenHelper, ICorrelationIdHelper correlationIdHelper, ILogger logger, IAzureBusHelper <TAuthenticationToken> azureBusHelper, IBusHelper busHelper, IHashAlgorithmFactory hashAlgorithmFactory, bool isAPublisher)
            : base(configurationManager, messageSerialiser, authenticationTokenHelper, correlationIdHelper, logger, isAPublisher)
        {
            AzureBusHelper                 = azureBusHelper;
            BusHelper                      = busHelper;
            TelemetryHelper                = new NullTelemetryHelper();
            PrivateServiceBusReceivers     = new Dictionary <int, IMessageReceiver>();
            PublicServiceBusReceivers      = new Dictionary <int, IMessageReceiver>();
            TimeoutOnSendRetryMaximumCount = 1;
            string timeoutOnSendRetryMaximumCountValue;
            short  timeoutOnSendRetryMaximumCount;

            if (ConfigurationManager.TryGetSetting("Cqrs.Azure.Servicebus.TimeoutOnSendRetryMaximumCount", out timeoutOnSendRetryMaximumCountValue) && !string.IsNullOrWhiteSpace(timeoutOnSendRetryMaximumCountValue) && short.TryParse(timeoutOnSendRetryMaximumCountValue, out timeoutOnSendRetryMaximumCount))
            {
                TimeoutOnSendRetryMaximumCount = timeoutOnSendRetryMaximumCount;
            }
            ExclusionNamespaces = new SynchronizedCollection <string> {
                "Cqrs", "System"
            };
            Signer = hashAlgorithmFactory;
        }
Exemplo n.º 8
0
 public AlgorithmPropertyHash(IHashAlgorithmFactory algorithmFactory)
 {
     _algorithmFactory = algorithmFactory;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Instantiates a new instance of <see cref="AzureEventHub{TAuthenticationToken}"/>
 /// </summary>
 protected AzureEventHub(IConfigurationManager configurationManager, IMessageSerialiser <TAuthenticationToken> messageSerialiser, IAuthenticationTokenHelper <TAuthenticationToken> authenticationTokenHelper, ICorrelationIdHelper correlationIdHelper, ILogger logger, IHashAlgorithmFactory hashAlgorithmFactory, bool isAPublisher)
     : base(configurationManager, messageSerialiser, authenticationTokenHelper, correlationIdHelper, logger, isAPublisher)
 {
     TelemetryHelper     = new NullTelemetryHelper();
     ExclusionNamespaces = new SynchronizedCollection <string> {
         "Cqrs", "System"
     };
     Signer = hashAlgorithmFactory;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Instantiates a new instance of <see cref="AzureBusHelper{TAuthenticationToken}"/>.
 /// </summary>
 public AzureBusHelper(IAuthenticationTokenHelper <TAuthenticationToken> authenticationTokenHelper, ICorrelationIdHelper correlationIdHelper, ILogger logger, IMessageSerialiser <TAuthenticationToken> messageSerialiser, IBusHelper busHelper, IHashAlgorithmFactory hashAlgorithmFactory, IConfigurationManager configurationManager, IDependencyResolver dependencyResolver)
 {
     AuthenticationTokenHelper = authenticationTokenHelper;
     CorrelationIdHelper       = correlationIdHelper;
     Logger               = logger;
     MessageSerialiser    = messageSerialiser;
     BusHelper            = busHelper;
     DependencyResolver   = dependencyResolver;
     ConfigurationManager = configurationManager;
     Signer               = hashAlgorithmFactory;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Constructs a factory for creating named GUIDs.
        /// </summary>
        /// <param name="algorithmFactory">Hash algorithm factory.</param>

        public NamedGuidFactory(IHashAlgorithmFactory algorithmFactory)
        {
            this.algorithmFactory = algorithmFactory ?? throw new ArgumentNullException(nameof(algorithmFactory));
        }
Exemplo n.º 12
0
 public PackageSchemaValidator(IDerivationStrategyFactory derivationServiceFactory, IMerkleStrategyFactory merkleStrategyFactory, IHashAlgorithmFactory hashAlgorithmFactory, IPackageBinary packageBinary, IValidatorFactory validatorFactory)
 {
     _derivationServiceFactory = derivationServiceFactory;
     _merkleStrategyFactory    = merkleStrategyFactory;
     _hashAlgorithmFactory     = hashAlgorithmFactory;
     _packageBinary            = packageBinary;
     _validatorFactory         = validatorFactory;
 }
Exemplo n.º 13
0
 public ValidationEngine(IPackageBinary packageBinary, IDerivationStrategyFactory derivationStrategyFactory, IMerkleStrategyFactory merkleStrategyFactory, IHashAlgorithmFactory hashAlgorithmFactory, TrustSchemaValidationOptions options, IValidatorFactory validatorFactory)
 {
     _packageBinary             = packageBinary;
     _derivationStrategyFactory = derivationStrategyFactory;
     _merkleStrategyFactory     = merkleStrategyFactory;
     _hashAlgorithmFactory      = hashAlgorithmFactory;
     _options          = options;
     _validatorFactory = validatorFactory;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes the hasher.
 /// </summary>
 /// <param name="hashAlgorithmName">The hash algorithm.</param>
 protected void InitializeHasher(
     string hashAlgorithmName)
 {
     _hashAlgorithmFactory = ServiceLocatorWrapper.Default.GetInstance <IHashAlgorithmFactory>();
     _hashAlgorithmFactory.Initialize(hashAlgorithmName);
 }