Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalDatasetDistributor"/> class.
        /// </summary>
        /// <param name="localDistributor">The object that handles distribution proposals for the local machine.</param>
        /// <param name="loader">The object that handles the actual starting of the dataset application.</param>
        /// <param name="commandHub">The object that sends commands to remote endpoints.</param>
        /// <param name="notificationHub">The object that receives notifications from remote endpoints.</param>
        /// <param name="uploads">The object that stores all the uploads waiting to be started.</param>
        /// <param name="datasetInformationBuilder">The function that builds <see cref="DatasetOnlineInformation"/> objects.</param>
        /// <param name="communicationLayer">The object that handles the communication for the application.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <param name="scheduler">The scheduler that is used to run the tasks on.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="localDistributor"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="loader"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commandHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notificationHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="datasetInformationBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="communicationLayer"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public LocalDatasetDistributor(
            ICalculateDistributionParameters localDistributor,
            IDatasetActivator loader,
            ISendCommandsToRemoteEndpoints commandHub,
            INotifyOfRemoteEndpointEvents notificationHub,
            IStoreUploads uploads,
            Func <DatasetId, EndpointId, NetworkIdentifier, DatasetOnlineInformation> datasetInformationBuilder,
            ICommunicationLayer communicationLayer,
            SystemDiagnostics systemDiagnostics,
            TaskScheduler scheduler = null)
        {
            {
                Enforce.Argument(() => localDistributor);
                Enforce.Argument(() => loader);
                Enforce.Argument(() => commandHub);
                Enforce.Argument(() => notificationHub);
                Enforce.Argument(() => datasetInformationBuilder);
                Enforce.Argument(() => communicationLayer);
                Enforce.Argument(() => systemDiagnostics);
            }

            m_LocalDistributor          = localDistributor;
            m_Loader                    = loader;
            m_CommandHub                = commandHub;
            m_NotificationHub           = notificationHub;
            m_Uploads                   = uploads;
            m_DatasetInformationBuilder = datasetInformationBuilder;
            m_CommunicationLayer        = communicationLayer;
            m_Diagnostics               = systemDiagnostics;
            m_Scheduler                 = scheduler ?? TaskScheduler.Default;
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommunicationPassThrough"/> class.
 /// </summary>
 /// <param name="commands">The object that sends commands to the remote endpoints.</param>
 /// <param name="uploads">The object that tracks files registered for upload.</param>
 /// <param name="localNotifications">The object that holds the notifications.</param>
 public CommunicationPassThrough(
     ISendCommandsToRemoteEndpoints commands,
     IStoreUploads uploads,
     TestNotifications localNotifications)
 {
     m_Commands           = commands;
     m_Uploads            = uploads;
     m_LocalNotifications = localNotifications;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ActivePhysicalMachineEnvironment"/> class.
 /// </summary>
 /// <param name="id">The ID of the environment.</param>
 /// <param name="terminateEnvironment">The action used to terminate the environment.</param>
 /// <param name="commands">The object that provides the commands used to communicate with the environment.</param>
 /// <param name="notifications">The object that provides notifications from the environment.</param>
 /// <param name="uploads">The object that tracks the files available for upload.</param>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="id"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="terminateEnvironment"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="commands"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="notifications"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
 /// </exception>
 public ActivePhysicalMachineEnvironment(
     string id,
     Action terminateEnvironment,
     IExecuteTestStepsCommands commands,
     ITestExecutionNotifications notifications,
     IStoreUploads uploads)
     : base(id, terminateEnvironment, commands, notifications, uploads)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="TransferTestDataCommands"/> class.
        /// </summary>
        /// <param name="uploads">The object that stores the files waiting for upload.</param>
        /// <param name="testInformation">The object that stores information about the currently active test.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="testInformation"/> is <see langword="null" />.
        /// </exception>
        public TransferTestDataCommands(IStoreUploads uploads, ActiveTestInformation testInformation)
        {
            {
                Lokad.Enforce.Argument(() => uploads);
                Lokad.Enforce.Argument(() => testInformation);
            }

            m_Uploads = uploads;
            m_TestInformation = testInformation;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PhysicalMachineEnvironmentActivator"/> class.
 /// </summary>
 /// <param name="configuration">The object that stores all the configuration values for the application.</param>
 /// <param name="commands">The object that stores all the command sets that were received from remote endpoints.</param>
 /// <param name="notifications">The object that provides notifications from remote endpoints.</param>
 /// <param name="disconnection">The delegate used to notify the communication system of the disconnection of an endpoint.</param>
 /// <param name="uploads">The object that tracks the files available for upload.</param>
 /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="configuration"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="commands"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="notifications"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="disconnection"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
 /// </exception>
 public PhysicalMachineEnvironmentActivator(
     IConfiguration configuration,
     ISendCommandsToRemoteEndpoints commands,
     INotifyOfRemoteEndpointEvents notifications,
     ManualEndpointDisconnection disconnection,
     IStoreUploads uploads,
     SystemDiagnostics diagnostics)
     : base(configuration, commands, notifications, disconnection, uploads, diagnostics)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="HostApplicationCommands"/> class.
        /// </summary>
        /// <param name="fileSystem">The object that provides a virtualizing layer for the file system.</param>
        /// <param name="uploads">
        /// The object that stores references to all the files that are about to be uploaded or
        /// are currently being uploaded.
        /// </param>
        /// <param name="configuration">The object that stores the configuration for the current application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="fileSystem"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="configuration"/> is <see langword="null" />.
        /// </exception>
        public HostApplicationCommands(IFileSystem fileSystem, IStoreUploads uploads, IConfiguration configuration)
        {
            {
                Lokad.Enforce.Argument(() => fileSystem);
                Lokad.Enforce.Argument(() => uploads);
                Lokad.Enforce.Argument(() => configuration);
            }

            m_FileSystem       = fileSystem;
            m_UploadCollection = uploads;
            m_Configuration    = configuration;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HostApplicationCommands"/> class.
        /// </summary>
        /// <param name="fileSystem">The object that provides a virtualizing layer for the file system.</param>
        /// <param name="uploads">
        /// The object that stores references to all the files that are about to be uploaded or
        /// are currently being uploaded.
        /// </param>
        /// <param name="configuration">The object that stores the configuration for the current application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="fileSystem"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="configuration"/> is <see langword="null" />.
        /// </exception>
        public HostApplicationCommands(IFileSystem fileSystem, IStoreUploads uploads, IConfiguration configuration)
        {
            {
                Lokad.Enforce.Argument(() => fileSystem);
                Lokad.Enforce.Argument(() => uploads);
                Lokad.Enforce.Argument(() => configuration);
            }

            m_FileSystem = fileSystem;
            m_UploadCollection = uploads;
            m_Configuration = configuration;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HypervEnvironmentActivator"/> class.
        /// </summary>
        /// <param name="configuration">The object that stores all the configuration values for the application.</param>
        /// <param name="commands">The object that stores all the command sets that were received from remote endpoints.</param>
        /// <param name="notifications">The object that provides notifications from remote endpoints.</param>
        /// <param name="disconnection">The delegate used to notify the communication system of the disconnection of an endpoint.</param>
        /// <param name="uploads">The object that tracks the files available for upload.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <param name="environmentById">The function that is used to find environments based on their ID.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="configuration"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commands"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notifications"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="disconnection"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="environmentById"/> is <see langword="null" />.
        /// </exception>
        public HypervEnvironmentActivator(
            IConfiguration configuration,
            ISendCommandsToRemoteEndpoints commands,
            INotifyOfRemoteEndpointEvents notifications,
            ManualEndpointDisconnection disconnection,
            IStoreUploads uploads,
            SystemDiagnostics diagnostics,
            Func<string, MachineDescription> environmentById)
            : base(configuration, commands, notifications, disconnection, uploads, diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => environmentById);
            }

            m_EnvironmentById = environmentById;
        }
Example #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataDownloadProcessAction"/> class.
        /// </summary>
        /// <param name="uploads">The object that stores the files that need uploading.</param>
        /// <param name="layer">The object that handles the communication with remote endpoints.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <param name="scheduler">The scheduler that is used to run the tasks on.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="layer"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public DataDownloadProcessAction(
            IStoreUploads uploads,
            IProtocolLayer layer,
            SystemDiagnostics systemDiagnostics,
            TaskScheduler scheduler = null)
        {
            {
                Lokad.Enforce.Argument(() => uploads);
                Lokad.Enforce.Argument(() => layer);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_Uploads     = uploads;
            m_Layer       = layer;
            m_Diagnostics = systemDiagnostics;
            m_Scheduler   = scheduler;
        }
Example #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RemoteDatasetDistributor"/> class.
        /// </summary>
        /// <param name="configuration">The application specific configuration.</param>
        /// <param name="commandHub">The object that manages the remote command proxies.</param>
        /// <param name="notificationHub">The object that receives notifications from remote endpoints.</param>
        /// <param name="uploads">The object that stores all the uploads waiting to be started.</param>
        /// <param name="datasetInformationBuilder">The function that builds <see cref="DatasetOnlineInformation"/> objects.</param>
        /// <param name="communicationLayer">The object that handles the communication for the application.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <param name="scheduler">The scheduler that is used to run the tasks.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commandHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notificationHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="configuration"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="datasetInformationBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="communicationLayer"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public RemoteDatasetDistributor(
            IConfiguration configuration,
            ISendCommandsToRemoteEndpoints commandHub,
            INotifyOfRemoteEndpointEvents notificationHub,
            IStoreUploads uploads,
            Func <DatasetId, EndpointId, NetworkIdentifier, DatasetOnlineInformation> datasetInformationBuilder,
            ICommunicationLayer communicationLayer,
            SystemDiagnostics systemDiagnostics,
            TaskScheduler scheduler = null)
        {
            {
                Lokad.Enforce.Argument(() => commandHub);
                Lokad.Enforce.Argument(() => notificationHub);
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => datasetInformationBuilder);
                Lokad.Enforce.Argument(() => communicationLayer);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_Configuration             = configuration;
            m_Uploads                   = uploads;
            m_DatasetInformationBuilder = datasetInformationBuilder;
            m_CommunicationLayer        = communicationLayer;
            m_Diagnostics               = systemDiagnostics;
            m_Scheduler                 = scheduler ?? TaskScheduler.Default;
            m_CommandHub                = commandHub;
            {
                // Set up the events so that we can see the loaders come online.
                //
                // Note that the events may come in on a different thread than the one
                // we're normally accessed on. This is because adding an enpoint is usually
                // a result of a WCF message being received, on the WCF message thread.
                m_CommandHub.OnEndpointSignedIn  += (s, e) => AddNewEndpoint(e.Endpoint, e.Commands);
                m_CommandHub.OnEndpointSignedOff += (s, e) => RemoveEndpoint(e.Endpoint);

                var knownCommands = m_CommandHub.AvailableCommands();
                foreach (var command in knownCommands)
                {
                    AddNewEndpoint(command.Endpoint, command.RegisteredCommands);
                }
            }

            m_NotificationHub = notificationHub;
        }
        /// <summary>
        /// Constructs a new active environment proxy.
        /// </summary>
        /// <param name="environment">The specification for the environment.</param>
        /// <param name="preTerminateEnvironment">The action executed just prior to terminating the environment.</param>
        /// <param name="postTerminateEnvironment">The action executed after terminating the environment.</param>
        /// <param name="commands">The object that provides the commands used to communicate with the environment.</param>
        /// <param name="notifications">The object that provides notifications from the environment.</param>
        /// <param name="uploads">The object that tracks the files available for upload.</param>
        /// <param name="sectionBuilder">
        /// The object used to write information to the report about the starting and stopping of the environment.
        /// </param>
        /// <returns>A new active environment proxy object.</returns>
        protected override IActiveEnvironment ConstructEnvironmentProxy(
            MachineDescription environment,
            Action preTerminateEnvironment,
            Action postTerminateEnvironment,
            IExecuteTestStepsCommands commands,
            ITestExecutionNotifications notifications,
            IStoreUploads uploads,
            ITestSectionBuilder sectionBuilder)
        {
            Action shutDownAction =
                () =>
                {
                    preTerminateEnvironment();
                    postTerminateEnvironment();

                    sectionBuilder.AddInformationMessage(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "Terminated machine: {0}",
                            environment.NetworkName));
                    sectionBuilder.FinalizeAndStore(true);
                };

            return new ActivePhysicalMachineEnvironment(
                environment.Id,
                shutDownAction,
                commands,
                notifications,
                uploads);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RemoteDatasetDistributor"/> class.
        /// </summary>
        /// <param name="configuration">The application specific configuration.</param>
        /// <param name="commandHub">The object that manages the remote command proxies.</param>
        /// <param name="notificationHub">The object that receives notifications from remote endpoints.</param>
        /// <param name="uploads">The object that stores all the uploads waiting to be started.</param>
        /// <param name="datasetInformationBuilder">The function that builds <see cref="DatasetOnlineInformation"/> objects.</param>
        /// <param name="communicationLayer">The object that handles the communication for the application.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <param name="scheduler">The scheduler that is used to run the tasks.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commandHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notificationHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="configuration"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="datasetInformationBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="communicationLayer"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public RemoteDatasetDistributor(
            IConfiguration configuration,
            ISendCommandsToRemoteEndpoints commandHub,
            INotifyOfRemoteEndpointEvents notificationHub,
            IStoreUploads uploads,
            Func<DatasetId, EndpointId, NetworkIdentifier, DatasetOnlineInformation> datasetInformationBuilder,
            ICommunicationLayer communicationLayer,
            SystemDiagnostics systemDiagnostics,
            TaskScheduler scheduler = null)
        {
            {
                Lokad.Enforce.Argument(() => commandHub);
                Lokad.Enforce.Argument(() => notificationHub);
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => datasetInformationBuilder);
                Lokad.Enforce.Argument(() => communicationLayer);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_Configuration = configuration;
            m_Uploads = uploads;
            m_DatasetInformationBuilder = datasetInformationBuilder;
            m_CommunicationLayer = communicationLayer;
            m_Diagnostics = systemDiagnostics;
            m_Scheduler = scheduler ?? TaskScheduler.Default;
            m_CommandHub = commandHub;
            {
                // Set up the events so that we can see the loaders come online.
                //
                // Note that the events may come in on a different thread than the one
                // we're normally accessed on. This is because adding an enpoint is usually
                // a result of a WCF message being received, on the WCF message thread.
                m_CommandHub.OnEndpointSignedIn += (s, e) => AddNewEndpoint(e.Endpoint, e.Commands);
                m_CommandHub.OnEndpointSignedOff += (s, e) => RemoveEndpoint(e.Endpoint);

                var knownCommands = m_CommandHub.AvailableCommands();
                foreach (var command in knownCommands)
                {
                    AddNewEndpoint(command.Endpoint, command.RegisteredCommands);
                }
            }

            m_NotificationHub = notificationHub;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ActiveMachineEnvironment"/> class.
        /// </summary>
        /// <param name="id">The ID of the environment.</param>
        /// <param name="terminateEnvironment">The action used to terminate the environment.</param>
        /// <param name="commands">The object that provides the commands used to communicate with the environment.</param>
        /// <param name="notifications">The object that provides notifications from the environment.</param>
        /// <param name="uploads">The object that tracks the files available for upload.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="id"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="terminateEnvironment"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commands"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notifications"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        protected ActiveMachineEnvironment(
            string id,
            Action terminateEnvironment,
            IExecuteTestStepsCommands commands,
            ITestExecutionNotifications notifications,
            IStoreUploads uploads)
        {
            {
                Lokad.Enforce.Argument(() => id);
                Lokad.Enforce.Argument(() => terminateEnvironment);
                Lokad.Enforce.Argument(() => commands);
                Lokad.Enforce.Argument(() => notifications);
                Lokad.Enforce.Argument(() => uploads);
            }

            m_Id = id;
            m_TerminateEnvironment = terminateEnvironment;
            m_Commands = commands;
            m_Uploads = uploads;

            m_Notifications = notifications;
            m_Notifications.OnExecutionProgress += HandleOnExecutionProgress;
            m_Notifications.OnTestCompletion += HandleOnTestCompletion;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalDatasetDistributor"/> class.
        /// </summary>
        /// <param name="localDistributor">The object that handles distribution proposals for the local machine.</param>
        /// <param name="loader">The object that handles the actual starting of the dataset application.</param>
        /// <param name="commandHub">The object that sends commands to remote endpoints.</param>
        /// <param name="notificationHub">The object that receives notifications from remote endpoints.</param>
        /// <param name="uploads">The object that stores all the uploads waiting to be started.</param>
        /// <param name="datasetInformationBuilder">The function that builds <see cref="DatasetOnlineInformation"/> objects.</param>
        /// <param name="communicationLayer">The object that handles the communication for the application.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <param name="scheduler">The scheduler that is used to run the tasks on.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="localDistributor"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="loader"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commandHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notificationHub"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="datasetInformationBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="communicationLayer"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public LocalDatasetDistributor(
            ICalculateDistributionParameters localDistributor,
            IDatasetActivator loader,
            ISendCommandsToRemoteEndpoints commandHub,
            INotifyOfRemoteEndpointEvents notificationHub,
            IStoreUploads uploads,
            Func<DatasetId, EndpointId, NetworkIdentifier, DatasetOnlineInformation> datasetInformationBuilder,
            ICommunicationLayer communicationLayer,
            SystemDiagnostics systemDiagnostics,
            TaskScheduler scheduler = null)
        {
            {
                Enforce.Argument(() => localDistributor);
                Enforce.Argument(() => loader);
                Enforce.Argument(() => commandHub);
                Enforce.Argument(() => notificationHub);
                Enforce.Argument(() => datasetInformationBuilder);
                Enforce.Argument(() => communicationLayer);
                Enforce.Argument(() => systemDiagnostics);
            }

            m_LocalDistributor = localDistributor;
            m_Loader = loader;
            m_CommandHub = commandHub;
            m_NotificationHub = notificationHub;
            m_Uploads = uploads;
            m_DatasetInformationBuilder = datasetInformationBuilder;
            m_CommunicationLayer = communicationLayer;
            m_Diagnostics = systemDiagnostics;
            m_Scheduler = scheduler ?? TaskScheduler.Default;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MachineEnvironmentActivator"/> class.
        /// </summary>
        /// <param name="configuration">The object that stores all the configuration values for the application.</param>
        /// <param name="commands">The object that stores all the command sets that were received from remote endpoints.</param>
        /// <param name="notifications">The object that provides notifications from remote endpoints.</param>
        /// <param name="disconnection">The delegate used to notify the communication system of the disconnection of an endpoint.</param>
        /// <param name="uploads">The object that tracks the files available for upload.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="configuration"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commands"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notifications"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="disconnection"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        protected MachineEnvironmentActivator(
            IConfiguration configuration,
            ISendCommandsToRemoteEndpoints commands,
            INotifyOfRemoteEndpointEvents notifications,
            ManualEndpointDisconnection disconnection,
            IStoreUploads uploads,
            SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => commands);
                Lokad.Enforce.Argument(() => notifications);
                Lokad.Enforce.Argument(() => disconnection);
                Lokad.Enforce.Argument(() => uploads);
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Configuration = configuration;
            m_Commands = commands;
            m_Notifications = notifications;
            m_Disconnection = disconnection;
            m_Uploads = uploads;
            m_Diagnostics = diagnostics;
        }
 /// <summary>
 /// Constructs a new active environment proxy.
 /// </summary>
 /// <param name="environment">The specification for the environment.</param>
 /// <param name="preTerminateEnvironment">The action executed just prior to terminating the environment.</param>
 /// <param name="postTerminateEnvironment">The action executed after terminating the environment.</param>
 /// <param name="commands">The object that provides the commands used to communicate with the environment.</param>
 /// <param name="notifications">The object that provides notifications from the environment.</param>
 /// <param name="uploads">The object that tracks the files available for upload.</param>
 /// <param name="sectionBuilder">
 /// The object used to write information to the report about the starting and stopping of the environment.
 /// </param>
 /// <returns>A new active environment proxy object.</returns>
 protected abstract IActiveEnvironment ConstructEnvironmentProxy(
     MachineDescription environment,
     Action preTerminateEnvironment,
     Action postTerminateEnvironment,
     IExecuteTestStepsCommands commands,
     ITestExecutionNotifications notifications,
     IStoreUploads uploads,
     ITestSectionBuilder sectionBuilder);
        /// <summary>
        /// Initializes a new instance of the <see cref="TransferTestReportDataCommands"/> class.
        /// </summary>
        /// <param name="fileSystem">The object that provides access to the file system.</param>
        /// <param name="dataDownload">The function that handles the download of data from a remote endpoint.</param>
        /// <param name="remoteCommands">The object that sends commands to remote endpoints.</param>
        /// <param name="uploads">The object that stores links to all the files that should be uploaded.</param>
        /// <param name="testInformation">The object that stores information about the currently active test.</param>
        /// <param name="hostInformation">The object that stores information about the host.</param>
        /// <param name="storageDirectory">The directory in which all the report files are stored.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="fileSystem"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="dataDownload"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="remoteCommands"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="uploads"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="testInformation"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="hostInformation"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="storageDirectory"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public TransferTestReportDataCommands(
            IFileSystem fileSystem,
            DownloadDataFromRemoteEndpoints dataDownload,
            ISendCommandsToRemoteEndpoints remoteCommands,
            IStoreUploads uploads,
            ActiveTestInformation testInformation,
            HostInformationStorage hostInformation,
            string storageDirectory,
            SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => fileSystem);
                Lokad.Enforce.Argument(() => dataDownload);
                Lokad.Enforce.Argument(() => remoteCommands);
                Lokad.Enforce.Argument(() => uploads);
                Lokad.Enforce.Argument(() => testInformation);
                Lokad.Enforce.Argument(() => hostInformation);
                Lokad.Enforce.Argument(() => storageDirectory);
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_FileSystem = fileSystem;
            m_DataDownload = dataDownload;
            m_RemoteCommands = remoteCommands;
            m_Uploads = uploads;
            m_TestInformation = testInformation;
            m_HostInformation = hostInformation;
            m_StorageDirectory = storageDirectory;
            m_Diagnostics = diagnostics;
        }
        /// <summary>
        /// Constructs a new active environment proxy.
        /// </summary>
        /// <param name="environment">The specification for the environment.</param>
        /// <param name="preTerminateEnvironment">The action executed just prior to terminating the environment.</param>
        /// <param name="postTerminateEnvironment">The action executed after terminating the environment.</param>
        /// <param name="commands">The object that provides the commands used to communicate with the environment.</param>
        /// <param name="notifications">The object that provides notifications from the environment.</param>
        /// <param name="uploads">The object that tracks the files available for upload.</param>
        /// <param name="sectionBuilder">
        /// The object used to write information to the report about the starting and stopping of the environment.
        /// </param>
        /// <returns>A new active environment proxy object.</returns>
        protected override IActiveEnvironment ConstructEnvironmentProxy(
            MachineDescription environment,
            Action preTerminateEnvironment,
            Action postTerminateEnvironment,
            IExecuteTestStepsCommands commands,
            ITestExecutionNotifications notifications,
            IStoreUploads uploads,
            ITestSectionBuilder sectionBuilder)
        {
            Action shutDownAction =
                () =>
                {
                    preTerminateEnvironment();
                    ShutdownVirtualMachine(environment, sectionBuilder);
                    postTerminateEnvironment();
                };

            return new ActiveHypervEnvironment(
                environment.Id,
                shutDownAction,
                commands,
                notifications,
                uploads);
        }