Beispiel #1
0
        private static void CreateStorageDirectory(IFileSystem fileSystem, string storageDirectory, SystemDiagnostics diagnostics)
        {
            if (fileSystem.Directory.Exists(storageDirectory))
            {
                diagnostics.Log(
                    LevelToLog.Info,
                    ExecutorConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.Log_Messages_RemovingStorageDirectory_WithDirectory,
                        storageDirectory));

                fileSystem.Directory.Delete(storageDirectory, true);
            }

            if (!fileSystem.Directory.Exists(storageDirectory))
            {
                diagnostics.Log(
                    LevelToLog.Debug,
                    ExecutorConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.Log_Messages_CreatingStorageDirectory_WithDirectory,
                        storageDirectory));

                fileSystem.Directory.CreateDirectory(storageDirectory);
            }
        }
        public void CreateWithEmptyInstallDirectory()
        {
            RetrieveFileDataForTestStep testFileLocation = index => @"c:\a\b";
            UploadReportFilesForTestStep uploader = (index, upload) => { };

            var fileSystem = new System.IO.Abstractions.TestingHelpers.MockFileSystem(
                new Dictionary<string, System.IO.Abstractions.TestingHelpers.MockFileData>
                    {
                        { @"c:\d\e\f.ps1", new System.IO.Abstractions.TestingHelpers.MockFileData("throw 'FAIL'") }
                    });

            var sectionBuilder = new Mock<ITestSectionBuilder>();
            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var installer = new XCopyDeployTestStepProcessor(
               testFileLocation,
               uploader,
               diagnostics,
               fileSystem,
               sectionBuilder.Object);

            var data = new XCopyTestStep
                {
                    pk_TestStepId = 1,
                    Order = 2,
                    Destination = @"c:\d\e",
                };

            var result = installer.Process(data, new List<InputParameter>());
            Assert.AreEqual(TestExecutionState.Passed, result);
        }
        public void Add()
        {
            var notifications = new List<TestCompletedNotification>
                {
                    new FileBasedTestCompletedNotification("b"),
                };

            var report = new Mock<IReport>();
            var builder = new Mock<IReportBuilder>();
            {
                builder.Setup(b => b.Build())
                    .Returns(report.Object);
            }

            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var storage = new ActiveTestStorage(diagnostics);

            var testId = 10;
            storage.Add(testId, builder.Object, notifications);

            Assert.That(
                storage.NotificationsFor(testId),
                Is.EquivalentTo(notifications));
            Assert.AreSame(report.Object, storage.ReportFor(testId));
        }
        public void RegisterNotification()
        {
            NotificationName notification = null;
            Action<INotificationArguments> action = null;

            var service = new Mock<IUserInterfaceService>();
            {
                service.Setup(s => s.RegisterNotification(It.IsAny<NotificationName>(), It.IsAny<Action<INotificationArguments>>()))
                    .Callback<NotificationName, Action<INotificationArguments>>(
                        (n, o) =>
                            {
                                notification = n;
                                action = o;
                            });
            }

            var notificationNames = new Mock<INotificationNameConstants>();
            {
                notificationNames.Setup(n => n.SystemShuttingDown)
                    .Returns(new NotificationName("a"));
            }

            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var facade = new ApplicationFacade(service.Object, notificationNames.Object, systemDiagnostics);

            var name = new NotificationName("bla");
            Action<INotificationArguments> callback = o => { };
            facade.RegisterNotification(name, callback);

            Assert.AreSame(name, notification);
            Assert.AreSame(callback, action);
        }
        public void InstallWithPowershellFile()
        {
            RetrieveFileDataForTestStep testFileLocation = index => @"c:\a\b";
            UploadReportFilesForTestStep uploader = (index, upload) => { };

            var fileSystem = new MockFileSystem(
                new Dictionary<string, MockFileData>
                    {
                        { @"c:\a\b\c.ps1", new MockFileData("Out-Host -InputObject 'hello word'") }
                    });

            var sectionBuilder = new Mock<ITestSectionBuilder>();
            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var installer = new ScriptExecuteTestStepProcessor(
               testFileLocation,
               uploader,
               diagnostics,
               fileSystem,
               sectionBuilder.Object);

            var data = new ScriptExecuteTestStep
            {
                pk_TestStepId = 1,
                Order = 2,
                ScriptLanguage = ScriptLanguage.Powershell,
            };

            var result = installer.Process(data, new List<InputParameter>());
            Assert.AreEqual(TestExecutionState.Passed, result);
        }
        public void AddEnvironmentForTest()
        {
            var notifications = new List<TestCompletedNotification>();
            var builder = new Mock<IReportBuilder>();
            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var storage = new ActiveTestStorage(diagnostics);

            var testId = 10;
            storage.Add(testId, builder.Object, notifications);

            var environment = new Mock<IActiveEnvironment>();
            {
                environment.Setup(e => e.Environment)
                    .Returns("a");
            }

            storage.AddEnvironmentForTest(testId, environment.Object);

            Assert.That(
                storage.EnvironmentsForTest(testId),
                Is.EquivalentTo(
                    new List<IActiveEnvironment>
                        {
                            environment.Object
                        }));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FileWatcherBasedPackageUploader"/> class.
        /// </summary>
        /// <param name="packageQueue">The object that queues packages that need to be processed.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="diagnostics">The object providing the diagnostics methods for the application.</param>
        internal FileWatcherBasedPackageUploader(
            IQueueSymbolPackages packageQueue,
            IConfiguration configuration,
            SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => packageQueue);
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => diagnostics);

                Lokad.Enforce.With<ArgumentException>(
                    configuration.HasValueFor(CoreConfigurationKeys.s_UploadPath),
                    Resources.Exceptions_Messages_MissingConfigurationValue_WithKey,
                    CoreConfigurationKeys.s_UploadPath);
            }

            m_Queue = packageQueue;
            m_Diagnostics = diagnostics;

            var uploadPath = configuration.Value<string>(CoreConfigurationKeys.s_UploadPath);
            m_Watcher = new FileSystemWatcher
            {
                Path = uploadPath,
                Filter = "*.symbols.nupkg",
                EnableRaisingEvents = false,
                NotifyFilter = NotifyFilters.FileName | NotifyFilters.CreationTime,
            };

            m_Watcher.Created += HandleFileCreated;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ActiveTestStorage"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public ActiveTestStorage(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NucleiBasedTraceWriter"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public NucleiBasedTraceWriter(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LogForwardingPipe"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public LogForwardingPipe(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
Beispiel #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="KernelService"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        protected KernelService(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
Beispiel #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LogReporter"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public LogReporter(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PrismToDiagnosticsLogger"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public PrismToDiagnosticsLogger(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FeedbackIconView"/> class.
        /// </summary>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public FeedbackIconView(SystemDiagnostics systemDiagnostics)
            : this()
        {
            {
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_Diagnostics = systemDiagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WhiteLogRedirector"/> class.
        /// </summary>
        /// <param name="name">The name for the logger.</param>
        /// <param name="level">The default log level.</param>
        /// <param name="diagnostics">The object that provides the logging for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public WhiteLogRedirector(string name, LoggerLevel level, SystemDiagnostics diagnostics)
            : base(name, level)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;
        }
 /// <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="TestStepAdditionalReportFilesController"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="context"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public TestStepAdditionalReportFilesController(IProvideTestingContext context, SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => context);
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Context = context;
            m_Diagnostics = diagnostics;
        }
Beispiel #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DatasetActivator"/> class.
        /// </summary>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public DatasetActivator(SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Diagnostics = diagnostics;

            LoadDatasetDependencies();
        }
Beispiel #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CoreProxy"/> class.
        /// </summary>
        /// <param name="owner">The <see cref="Kernel"/> to which this proxy is linked.</param>
        /// <param name="diagnostics">The object that handles the diagnostics for the application.</param>
        /// <param name="scheduler">The scheduler that is used to run tasks.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="owner"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="diagnostics"/> is <see langword="null"/>.
        /// </exception>
        public CoreProxy(IKernel owner, SystemDiagnostics diagnostics, TaskScheduler scheduler = null)
            : base(diagnostics)
        {
            {
                Enforce.Argument(() => owner);
            }

            m_Owner = owner;
            m_Scheduler = scheduler ?? TaskScheduler.Default;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TestStepParameterController"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="context"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public TestStepParameterController(IProvideTestingContext context, SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => context);
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Context = context;
            m_Diagnostics = diagnostics;
        }
Beispiel #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PluginService"/> class.
        /// </summary>
        /// <param name="configuration">The object that stores the configuration for the current application.</param>
        /// <param name="detector">The object that detects the available plugins.</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="detector"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public PluginService(IConfiguration configuration, PluginDetector detector, SystemDiagnostics diagnostics)
            : base(diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => detector);
            }

            m_Configuration = configuration;
            m_Detector = detector;
        }
Beispiel #22
0
        public void InstallServiceThatDependsOnItself()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var testMock = new AdaptableKernelService(
                new[] { typeof(AdaptableKernelService) },
                systemDiagnostics);

            var kernel = new Kernel(
                () => { },
                systemDiagnostics);
            Assert.Throws<ServiceCannotDependOnItselfException>(() => kernel.Install(testMock));
        }
        public void MessageTypeToProcess()
        {
            var sink         = new Mock <IHandleProtocolHandshakes>();
            var channelTypes = new[]
            {
                ChannelTemplate.TcpIP
            };
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            var action = new EndpointConnectProcessAction(sink.Object, channelTypes, systemDiagnostics);

            Assert.AreEqual(typeof(EndpointConnectMessage), action.MessageTypeToProcess);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UserInterfaceBootstrapper"/> class.
        /// </summary>
        /// <param name="container">The container provides the shell components.</param>
        /// <param name="resetEvent">The reset event used to indicate to the application that it is safe to shut down.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="container"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="resetEvent"/> is <see langword="null" />.
        /// </exception>
        public UserInterfaceBootstrapper(IContainer container, AutoResetEvent resetEvent)
            : base(new AutofacContainerAdapter(container), new ModuleCatalog().AddModule(typeof(ExplorerUserInterfaceModule)))
        {
            {
                Enforce.Argument(() => container);
                Enforce.Argument(() => resetEvent);
            }

            m_ShellIocContainer = container;
            m_ResetEvent = resetEvent;
            m_Diagnostics = m_ShellIocContainer.Resolve<SystemDiagnostics>();
            m_Logger = new PrismToDiagnosticsLogger(m_Diagnostics);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UserInterfaceBootstrapper"/> class.
        /// </summary>
        /// <param name="container">The container provides the shell components.</param>
        /// <param name="resetEvent">The reset event used to indicate to the application that it is safe to shut down.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="container"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="resetEvent"/> is <see langword="null" />.
        /// </exception>
        public UserInterfaceBootstrapper(IContainer container, AutoResetEvent resetEvent)
            : base(new AutofacContainerAdapter(container), new ModuleCatalog().AddModule(typeof(ExplorerUserInterfaceModule)))
        {
            {
                Enforce.Argument(() => container);
                Enforce.Argument(() => resetEvent);
            }

            m_ShellIocContainer = container;
            m_ResetEvent        = resetEvent;
            m_Diagnostics       = m_ShellIocContainer.Resolve <SystemDiagnostics>();
            m_Logger            = new PrismToDiagnosticsLogger(m_Diagnostics);
        }
Beispiel #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteCommandHub"/> class.
 /// </summary>
 /// <param name="endpointInformationStorage">The object that provides notification of the signing in and signing out of endpoints.</param>
 /// <param name="builder">The object that is responsible for building the command proxies.</param>
 /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="endpointInformationStorage"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="builder"/> is <see langword="null" />.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
 /// </exception>
 internal RemoteCommandHub(
     IStoreInformationAboutEndpoints endpointInformationStorage,
     CommandProxyBuilder builder,
     SystemDiagnostics systemDiagnostics)
     : base(
         endpointInformationStorage,
         (endpoint, type) => (CommandSetProxy)builder.ProxyConnectingTo(endpoint, type),
         systemDiagnostics)
 {
     {
         Lokad.Enforce.Argument(() => builder);
     }
 }
        public void Stop()
        {
            var commands          = new Mock <ICommandContainer>();
            var notificationNames = new MockNotificationNameConstants();
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var builder           = new ContainerBuilder();
            {
                builder.Register(c => commands.Object).As <ICommandContainer>();
                builder.Register(c => notificationNames).As <INotificationNameConstants>();
                builder.Register(c => systemDiagnostics).As <SystemDiagnostics>();
            }

            Action <IContainer> onStartService = c => { };

            var service = new UserInterfaceService(
                builder.Build(),
                onStartService,
                systemDiagnostics);

            bool wasInvoked = false;

            service.RegisterNotification(notificationNames.SystemShuttingDown, obj => { wasInvoked = true; });

            var proxy = new CoreProxy(new Mock <IKernel>().Object, systemDiagnostics);

            service.ConnectTo(proxy);

            ITimeline timeline   = new Timeline(BuildStorage);
            var       proxyLayer = new Mock <IProxyCompositionLayer>();
            var       projects   = new ProjectService(
                () => timeline,
                d => new DatasetStorageProxy(
                    d,
                    new GroupSelector(
                        new Mock <IConnectGroups>().Object,
                        proxyLayer.Object),
                    proxyLayer.Object),
                new Mock <IHelpDistributingDatasets>().Object,
                new Mock <ICollectNotifications>().Object,
                systemDiagnostics,
                new Mock <IBuildProjects>().Object);

            service.ConnectTo(projects);

            service.Start();
            Assert.AreEqual(StartupState.Started, service.StartupState);

            service.Stop();
            Assert.AreEqual(StartupState.Stopped, service.StartupState);
            Assert.IsTrue(wasInvoked);
        }
Beispiel #28
0
        static void Main(string[] args)
        {
            Show TextDisplay = ShowText;

            // If args size is 0 or null, then we leave
            if (args.Length == 0)
            {
                TextDisplay(lambda_Err, "Veuillez entrer au moins un paramètre de démarrage.Les paramètres actuellement disponible sont ", LaunchOption);
                Console.ReadKey();
                return;
            }

            // Else, if the option is okay
            if (args[0] == LaunchOption)
            {
                try {
                    Process[] pname = Process.GetProcessesByName(ProcessName);
                    if (pname.Length >= 1)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        TextDisplay(lambda_Err, "Impossible de démarrer le programme car le processus est déjà en cours d'exécution.");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.ReadKey();
                        return;
                    }

                    if (SystemDiagnostics.CanLaunch())
                    {
                        TextDisplay(lambda_Cnl, "Veuillez choisir une option entre --Text");//, --Image et --Video.")
                        //var displayType = // Choisir entre --Text, --Image ou --Video (ce dernier ne sera pas utilisé)
                        ProcessStart.Invoke(Console.ReadLine());
                        StartService();
                    }
                } catch (RamException e) {
                    TextDisplay(lambda_Err, "Le processus ne peut pas être démarré. Raison : ", e.ToString());
                    Environment.Exit((int)(e.Status));
                }
                catch (CpuException e) {
                    TextDisplay(lambda_Err, "Le processus ne peut pas être démarré. Raison : ", e.ToString());
                    Environment.Exit((int)(e.Status));
                }
                catch (LauncherGenericException e) {
                    TextDisplay(lambda_Err, "Le processus ne peut pas être démarré. Raison : ", e.ToString());
                    Environment.Exit((int)(e.Status));
                }
                catch (Exception e) {
                    TextDisplay(lambda_Err, "Une erreur inconnue bloque le démarrage de l'application: ", e.Message, e.StackTrace);
                    Environment.Exit((int)(ExceptionStatus.INTERRUPT));
                }
            }
        }
        public void CommandsForWithUnknownCommand()
        {
            var localEndpoint = new EndpointId("local");
            var notifier      = new Mock <IStoreInformationAboutEndpoints>();
            var configuration = new Mock <IConfiguration>();
            {
                configuration.Setup(c => c.HasValueFor(It.IsAny <ConfigurationKey>()))
                .Returns(false);
            }

            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            SendMessageAndWaitForResponse sender =
                (e, m, r, t) => Task <ICommunicationMessage> .Factory.StartNew(
                    () => new SuccessMessage(localEndpoint, new MessageId()),
                    new CancellationToken(),
                    TaskCreationOptions.None,
                    new CurrentThreadTaskScheduler());

            var hub = new RemoteCommandHub(
                notifier.Object,
                new CommandProxyBuilder(
                    localEndpoint,
                    sender,
                    configuration.Object,
                    systemDiagnostics),
                systemDiagnostics);

            var endpoint = new EndpointId("other");
            var types    = new List <OfflineTypeInformation>
            {
                new OfflineTypeInformation(
                    typeof(InteractionExtensionsTest.IMockCommandSetWithTaskReturn).FullName,
                    typeof(InteractionExtensionsTest.IMockCommandSetWithTaskReturn).Assembly.GetName())
            };

            var eventWasTriggered = false;

            hub.OnEndpointConnected += (s, e) =>
            {
                eventWasTriggered = true;
                Assert.AreEqual(endpoint, e.Endpoint);
                Assert.IsTrue(hub.HasCommandFor(e.Endpoint, typeof(InteractionExtensionsTest.IMockCommandSetWithTaskReturn)));
            };

            hub.OnReceiptOfEndpointCommands(endpoint, types);
            Assert.IsTrue(eventWasTriggered);

            var commands = hub.CommandsFor <InteractionExtensionsTest.IMockCommandSetWithTypedTaskReturn>(endpoint);

            Assert.IsNull(commands);
        }
        public void Invoke()
        {
            var endpoint = new EndpointId("a");
            var group    = new[]
            {
                new CommunicationSubjectGroup(
                    new CommunicationSubject("a"),
                    new[]
                {
                    new VersionedTypeFallback(
                        new Tuple <OfflineTypeInformation, Version>(
                            new OfflineTypeInformation(
                                typeof(int).FullName,
                                typeof(int).Assembly.GetName()),
                            new Version(1, 0))),
                },
                    new[]
                {
                    new VersionedTypeFallback(
                        new Tuple <OfflineTypeInformation, Version>(
                            new OfflineTypeInformation(
                                typeof(double).FullName,
                                typeof(double).Assembly.GetName()),
                            new Version(1, 2))),
                }),
            };
            var message = new EndpointInteractionInformationMessage(endpoint, group);

            var handshake = new Mock <IHandleInteractionHandshakes>();
            {
                handshake.Setup(h => h.ContinueHandshakeWith(It.IsAny <EndpointId>(), It.IsAny <CommunicationSubjectGroup[]>(), It.IsAny <MessageId>()))
                .Callback <EndpointId, CommunicationSubjectGroup[], MessageId>(
                    (e, c, m) =>
                {
                    Assert.AreSame(endpoint, e);
                    Assert.AreSame(group, c);
                    Assert.AreSame(message.Id, m);
                })
                .Verifiable();
            }

            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            var action = new EndpointInteractionInformationProcessAction(handshake.Object, systemDiagnostics);

            action.Invoke(message);

            handshake.Verify(
                h => h.ContinueHandshakeWith(It.IsAny <EndpointId>(), It.IsAny <CommunicationSubjectGroup[]>(), It.IsAny <MessageId>()),
                Times.Once());
        }
Beispiel #31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProtocolHandshakeConductor"/> class.
        /// </summary>
        /// <param name="potentialEndpoints">The collection of endpoints that have been discovered.</param>
        /// <param name="discoveryChannel">The object that provides the information about the entry discovery channel for the application.</param>
        /// <param name="discoverySources">The object that handles the discovery of remote endpoints.</param>
        /// <param name="layer">The object responsible for sending messages with remote endpoints.</param>
        /// <param name="descriptions">The object that stores information about the available communication descriptions.</param>
        /// <param name="connectionApprovers">
        /// The collection that contains all the objects that are able to approve connections between the current endpoint and a remote endpoint.
        /// </param>
        /// <param name="allowedChannelTypes">The collection that contains all the channel types for which a channel should be opened.</param>
        /// <param name="configuration">The object that stores the configuration values for the application.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="potentialEndpoints"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="discoveryChannel"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="discoverySources"/> 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="descriptions"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="connectionApprovers"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="allowedChannelTypes"/> 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="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public ProtocolHandshakeConductor(
            IStoreEndpointApprovalState potentialEndpoints,
            IProvideLocalConnectionInformation discoveryChannel,
            IEnumerable <IDiscoverOtherServices> discoverySources,
            IProtocolLayer layer,
            IStoreProtocolSubjects descriptions,
            IEnumerable <IApproveEndpointConnections> connectionApprovers,
            IEnumerable <ChannelTemplate> allowedChannelTypes,
            IConfiguration configuration,
            SystemDiagnostics systemDiagnostics)
        {
            {
                Lokad.Enforce.Argument(() => potentialEndpoints);
                Lokad.Enforce.Argument(() => discoveryChannel);
                Lokad.Enforce.Argument(() => discoverySources);
                Lokad.Enforce.Argument(() => layer);
                Lokad.Enforce.Argument(() => descriptions);
                Lokad.Enforce.Argument(() => connectionApprovers);
                Lokad.Enforce.Argument(() => allowedChannelTypes);
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_PotentialEndpoints = potentialEndpoints;

            // Also handle the case where the endpoint signs out while it is trying to
            // connect to us
            m_PotentialEndpoints.OnEndpointDisconnected += HandleEndpointSignedOut;

            m_DiscoveryChannel    = discoveryChannel;
            m_DiscoverySources    = discoverySources;
            m_Layer               = layer;
            m_Descriptions        = descriptions;
            m_AllowedChannelTypes = allowedChannelTypes;
            m_Diagnostics         = systemDiagnostics;

            m_SendTimeout = configuration.HasValueFor(CommunicationConfigurationKeys.WaitForResponseTimeoutInMilliSeconds)
                ? TimeSpan.FromMilliseconds(configuration.Value <int>(CommunicationConfigurationKeys.WaitForResponseTimeoutInMilliSeconds))
                : TimeSpan.FromMilliseconds(CommunicationConstants.DefaultWaitForResponseTimeoutInMilliSeconds);

            foreach (var approver in connectionApprovers)
            {
                m_ConnectionApprovers.Add(approver.ProtocolVersion, approver);
            }

            foreach (var source in m_DiscoverySources)
            {
                source.OnEndpointBecomingAvailable   += HandleEndpointSignIn;
                source.OnEndpointBecomingUnavailable += HandleEndpointSignedOut;
            }
        }
        public void ProxyDisconnectFromEventWithNormalEventHandler()
        {
            var local = new EndpointId("local");
            UnregisterFromNotificationMessage intermediateMsg = null;
            SendMessage messageSender = (e, m, r) =>
            {
                intermediateMsg = m as UnregisterFromNotificationMessage;
            };

            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var builder           = new NotificationProxyBuilder(local, messageSender, systemDiagnostics);

            var remoteEndpoint = new EndpointId("other");
            var proxy          = builder.ProxyConnectingTo <InteractionExtensionsTest.IMockNotificationSetWithEventHandler>(remoteEndpoint);

            object    sender       = null;
            EventArgs receivedArgs = null;

            EventHandler handler =
                (s, e) =>
            {
                sender       = s;
                receivedArgs = e;
            };

            proxy.OnMyEvent += handler;

            Assert.IsNull(intermediateMsg);

            var notificationObj = proxy as NotificationSetProxy;

            Assert.IsNotNull(notificationObj);

            var id   = NotificationId.Create(typeof(InteractionExtensionsTest.IMockNotificationSetWithEventHandler).GetEvent("OnMyEvent"));
            var args = new EventArgs();

            notificationObj.RaiseEvent(id, args);

            Assert.AreSame(proxy, sender);
            Assert.AreSame(args, receivedArgs);

            sender           = null;
            receivedArgs     = null;
            proxy.OnMyEvent -= handler;

            Assert.AreEqual(id, intermediateMsg.Notification);

            notificationObj.RaiseEvent(id, new EventArgs());
            Assert.IsNull(sender);
            Assert.IsNull(receivedArgs);
        }
Beispiel #33
0
        public void AcceptStream()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var msg = new StreamData
            {
                Data = new MemoryStream(),
            };

            var endpoint = new DataReceivingEndpoint(systemDiagnostics);

            endpoint.OnNewData += (s, e) => Assert.AreSame(msg.Data, e.Data.Data);

            endpoint.AcceptStream(msg);
        }
        public void ConvertWithDistributionSuggestion()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var plan = CreateNewDistributionPlan(
                new DatasetActivationProposal(),
                CreateOfflineInfo(new Mock<IPersistenceInformation>().Object),
                systemDiagnostics);

            var model = new DistributionSuggestion(plan);

            var converter = new DistributionSuggestionToTextConverter();
            var convertedValue = converter.Convert(model, null, null, null);
            Assert.AreEqual(plan.MachineToDistributeTo.ToString(), convertedValue);
        }
Beispiel #35
0
        public void InvokeWithFailedChannel()
        {
            var         endpoint   = new EndpointId("id");
            SendMessage sendAction = (e, m, r) => { throw new Exception(); };

            int count             = 0;
            var systemDiagnostics = new SystemDiagnostics((p, s) => { count++; }, null);

            var action = new UnknownMessageTypeProcessAction(endpoint, sendAction, systemDiagnostics);

            action.Invoke(new SuccessMessage(new EndpointId("otherId"), new MessageId()));

            Assert.AreEqual(1, count);
        }
Beispiel #36
0
        public void FromUriWithCommunicationFault()
        {
            var protocolVersions = new[]
            {
                new Version(1, 0),
            };

            var configuration = new Mock <IConfiguration>();
            {
                configuration.Setup(c => c.HasValueFor(It.IsAny <ConfigurationKey>()))
                .Returns(false);
            }

            var template = new NamedPipeDiscoveryChannelTemplate(configuration.Object);
            Func <ChannelTemplate, IDiscoveryChannelTemplate> templateBuilder = t => template;

            var diagnostics = new SystemDiagnostics((l, s) => { }, null);
            var translator  = new DiscoveryChannelTranslator(
                protocolVersions,
                templateBuilder,
                diagnostics);

            var uri      = new Uri("net.pipe://localhost/pipe/discovery");
            var receiver = new MockEndpoint(
                () => DiscoveryVersions.V1,
                () =>
            {
                throw new ArgumentException();
            },
                null);

            var host    = new ServiceHost(receiver, uri);
            var binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
            {
                TransferMode = TransferMode.Buffered,
            };
            var address  = string.Format("{0}_{1}", "ThroughNamedPipe", Process.GetCurrentProcess().Id);
            var endpoint = host.AddServiceEndpoint(typeof(IInformationEndpoint), binding, address);

            host.Open();
            try
            {
                var info = translator.FromUri(endpoint.ListenUri);
                Assert.IsNull(info);
            }
            finally
            {
                host.Close();
            }
        }
Beispiel #37
0
        public void NotifyServicesOfStartupCompletion()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var kernel = new Mock<IKernel>();
            var service = new CoreProxy(kernel.Object, systemDiagnostics);

            bool wasInvoked = false;
            service.OnStartupComplete += (s, e) => { wasInvoked = true; };

            service.Start();
            service.NotifyServicesOfStartupCompletion();

            Assert.IsTrue(wasInvoked);
        }
        public void Install()
        {
            RetrieveFileDataForTestStep testFileLocation = index => @"c:\a\b";
            UploadReportFilesForTestStep uploader = (index, upload) => { };

            var runner = new Mock<IRunConsoleApplications>();
            {
                runner.Setup(r => r.Run(It.IsAny<string>(), It.IsAny<string[]>()))
                    .Callback(() => runner.Raise(r => r.OnConsoleOutput += null, new ProcessOutputEventArgs("foo")))
                    .Returns(0);
            }

            var fileSystem = new MockFileSystem(
                new Dictionary<string, MockFileData>
                    {
                        {
                            @"c:\a\b\c.msi", new MockFileData("Test file")
                        }
                    });

            var sectionBuilder = new Mock<ITestSectionBuilder>();
            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var installer = new MsiDeployTestStepProcessor(
                testFileLocation,
                uploader,
                diagnostics,
                runner.Object,
                fileSystem,
                sectionBuilder.Object);

            var parameters = new List<TestStepParameter>
                {
                    new TestStepParameter
                        {
                            Key = "Key",
                            Value = "Value",
                        },
                };

            var data = new MsiInstallTestStep
            {
                pk_TestStepId = 1,
                Order = 2,
                TestStepParameters = parameters,
            };

            var result = installer.Process(data, new List<InputParameter>());
            Assert.AreEqual(TestExecutionState.Passed, result);
        }
        public void InvokeWithIdAndContextFullyFunctional()
        {
            var commands = new Mock <ICommandContainer>();
            {
                commands.Setup(c => c.Invoke(It.IsAny <CommandId>(), It.IsAny <ICommandContext>()))
                .Verifiable();
            }

            var notificationNames = new MockNotificationNameConstants();
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var builder           = new ContainerBuilder();
            {
                builder.Register(c => commands.Object).As <ICommandContainer>();
                builder.Register(c => notificationNames).As <INotificationNameConstants>();
                builder.Register(c => systemDiagnostics).As <SystemDiagnostics>();
            }

            Action <IContainer> onStartService = c => { };

            var service = new UserInterfaceService(
                builder.Build(),
                onStartService,
                systemDiagnostics);

            var proxy = new CoreProxy(new Mock <IKernel>().Object, systemDiagnostics);

            service.ConnectTo(proxy);

            ITimeline timeline   = new Timeline(BuildStorage);
            var       proxyLayer = new Mock <IProxyCompositionLayer>();
            var       projects   = new ProjectService(
                () => timeline,
                d => new DatasetStorageProxy(
                    d,
                    new GroupSelector(
                        new Mock <IConnectGroups>().Object,
                        proxyLayer.Object),
                    proxyLayer.Object),
                new Mock <IHelpDistributingDatasets>().Object,
                new Mock <ICollectNotifications>().Object,
                systemDiagnostics,
                new Mock <IBuildProjects>().Object);

            service.ConnectTo(projects);
            service.Start();

            service.Invoke(new CommandId("bla"), new Mock <ICommandContext>().Object);
            commands.Verify(c => c.Invoke(It.IsAny <CommandId>(), It.IsAny <ICommandContext>()), Times.Exactly(1));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DatasetOnlineInformation"/> class.
        /// </summary>
        /// <param name="id">The ID number of the dataset.</param>
        /// <param name="endpoint">The ID number of the endpoint that has the actual dataset loaded.</param>
        /// <param name="networkId">The network identifier of the machine on which the dataset runs.</param>
        /// <param name="commandHub">The object that handles sending commands to the remote endpoint.</param>
        /// <param name="notificationHub">The object that handles the event notifications for remote endpoints.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="id"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="endpoint"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="networkId"/> 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="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public DatasetOnlineInformation(
            DatasetId id,
            EndpointId endpoint,
            NetworkIdentifier networkId,
            ISendCommandsToRemoteEndpoints commandHub,
            INotifyOfRemoteEndpointEvents notificationHub,
            SystemDiagnostics systemDiagnostics)
        {
            {
                Enforce.Argument(() => id);
                Enforce.Argument(() => endpoint);
                Enforce.Argument(() => networkId);
                Enforce.Argument(() => commandHub);
                Enforce.Argument(() => notificationHub);
                Enforce.Argument(() => systemDiagnostics);
            }

            Id            = id;
            Endpoint      = endpoint;
            RunsOn        = networkId;
            m_CommandHub  = commandHub;
            m_Diagnostics = systemDiagnostics;

            m_NotificationHub = notificationHub;
            {
                Debug.Assert(
                    m_NotificationHub.HasNotificationFor(Endpoint, typeof(IDatasetApplicationNotifications)),
                    "Missing essential notification set.");

                var notifications = m_NotificationHub.NotificationsFor <IDatasetApplicationNotifications>(Endpoint);
                notifications.OnSwitchToEditingMode +=
                    (s, e) =>
                {
                    m_IsEditMode = true;
                    RaiseOnSwitchToEditMode();
                };
                notifications.OnSwitchToExecutingMode +=
                    (s, e) =>
                {
                    m_IsEditMode = false;
                    RaiseOnSwitchToExecutingMode();
                };
                notifications.OnTimelineUpdate +=
                    (s, e) =>
                {
                    RaiseOnTimelineUpdate();
                };
            }
        }
        public void Close()
        {
            var id                = new DatasetId();
            var endpoint          = EndpointIdExtensions.CreateEndpointIdForCurrentProcess();
            var networkId         = NetworkIdentifier.ForLocalMachine();
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            var datasetCommands = new Mock <IDatasetApplicationCommands>();
            {
                datasetCommands.Setup(d => d.Close())
                .Returns(
                    Task.Factory.StartNew(
                        () => { },
                        new CancellationToken(),
                        TaskCreationOptions.None,
                        new CurrentThreadTaskScheduler()))
                .Verifiable();
            }

            var commandHub = new Mock <ISendCommandsToRemoteEndpoints>();
            {
                commandHub.Setup(h => h.HasCommandFor(It.IsAny <EndpointId>(), It.IsAny <Type>()))
                .Returns(true);
                commandHub.Setup(h => h.CommandsFor <IDatasetApplicationCommands>(It.IsAny <EndpointId>()))
                .Returns(datasetCommands.Object);
            }

            var notifications   = new Mock <IDatasetApplicationNotifications>();
            var notificationHub = new Mock <INotifyOfRemoteEndpointEvents>();
            {
                notificationHub.Setup(n => n.HasNotificationsFor(It.IsAny <EndpointId>()))
                .Returns(true);
                notificationHub.Setup(n => n.NotificationsFor <IDatasetApplicationNotifications>(It.IsAny <EndpointId>()))
                .Callback <EndpointId>(e => Assert.AreSame(endpoint, e))
                .Returns(notifications.Object);
            }

            var info = new DatasetOnlineInformation(
                id,
                endpoint,
                networkId,
                commandHub.Object,
                notificationHub.Object,
                systemDiagnostics);

            info.Close();

            datasetCommands.Verify(d => d.Close(), Times.Once());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AppDomainOwningPluginScanner"/> class.
        /// </summary>
        /// <param name="appDomainBuilder">The function that is used to create a new <c>AppDomain</c> which will be used to scan plugins.</param>
        /// <param name="repository">The object that contains the information about all the known parts and part groups.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the system.</param>
        public AppDomainOwningPluginScanner(
            Func<string, AppDomainPaths, AppDomain> appDomainBuilder,
            IPluginRepository repository,
            SystemDiagnostics diagnostics)
        {
            {
                Debug.Assert(appDomainBuilder != null, "The AppDomain building function should not be a null reference.");
                Debug.Assert(repository != null, "The repository object should not be a null reference.");
                Debug.Assert(diagnostics != null, "The diagnostics object should not be a null reference.");
            }

            m_AppDomainBuilder = appDomainBuilder;
            m_Repository = repository;
            m_Diagnostics = diagnostics;
        }
        public void ConvertWithDistributionSuggestion()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var plan = CreateNewDistributionPlan(
                new DatasetActivationProposal(),
                CreateOfflineInfo(new Mock <IPersistenceInformation>().Object),
                systemDiagnostics);

            var model = new DistributionSuggestion(plan);

            var converter      = new DistributionSuggestionToTextConverter();
            var convertedValue = converter.Convert(model, null, null, null);

            Assert.AreEqual(plan.MachineToDistributeTo.ToString(), convertedValue);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AppDomainOwningPluginScanner"/> class.
        /// </summary>
        /// <param name="appDomainBuilder">The function that is used to create a new <c>AppDomain</c> which will be used to scan plugins.</param>
        /// <param name="repository">The object that contains the information about all the known parts and part groups.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the system.</param>
        public AppDomainOwningPluginScanner(
            Func <string, AppDomainPaths, AppDomain> appDomainBuilder,
            IPluginRepository repository,
            SystemDiagnostics diagnostics)
        {
            {
                Debug.Assert(appDomainBuilder != null, "The AppDomain building function should not be a null reference.");
                Debug.Assert(repository != null, "The repository object should not be a null reference.");
                Debug.Assert(diagnostics != null, "The diagnostics object should not be a null reference.");
            }

            m_AppDomainBuilder = appDomainBuilder;
            m_Repository       = repository;
            m_Diagnostics      = diagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NotificationEventRemoveMethodInterceptor"/> class.
        /// </summary>
        /// <param name="proxyInterfaceType">The type of the interface for which a proxy is being provided.</param>
        /// <param name="transmitDeregistration">
        ///     The function used to send the information about the event unregistration to the owning endpoint.
        /// </param>
        /// <param name="systemDiagnostics">The object that provides the diagnostic methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="proxyInterfaceType"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="transmitDeregistration"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public NotificationEventRemoveMethodInterceptor(
            Type proxyInterfaceType,
            Action <NotificationId> transmitDeregistration,
            SystemDiagnostics systemDiagnostics)
        {
            {
                Lokad.Enforce.Argument(() => proxyInterfaceType);
                Lokad.Enforce.Argument(() => transmitDeregistration);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_InterfaceType          = proxyInterfaceType;
            m_TransmitDeregistration = transmitDeregistration;
            m_Diagnostics            = systemDiagnostics;
        }
Beispiel #46
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UnknownMessageTypeProcessAction"/> class.
        /// </summary>
        /// <param name="localEndpoint">The endpoint ID of the local endpoint.</param>
        /// <param name="sendMessage">The action that is used to send messages.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="localEndpoint"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="sendMessage"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public UnknownMessageTypeProcessAction(
            EndpointId localEndpoint,
            SendMessage sendMessage,
            SystemDiagnostics systemDiagnostics)
        {
            {
                Lokad.Enforce.Argument(() => localEndpoint);
                Lokad.Enforce.Argument(() => sendMessage);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_Current     = localEndpoint;
            m_SendMessage = sendMessage;
            m_Diagnostics = systemDiagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TestStepProcessor"/> class.
        /// </summary>
        /// <param name="testFileLocation">
        /// The function that takes the name of the test step and returns the full path to the directory containing the files for the 
        /// given test step.
        /// </param>
        /// <param name="reportFileUploader">
        /// The function that is used to upload the report files for the current test step.
        /// </param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="testFileLocation"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="reportFileUploader"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        protected TestStepProcessor(
            RetrieveFileDataForTestStep testFileLocation,
            UploadReportFilesForTestStep reportFileUploader,
            SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => testFileLocation);
                Lokad.Enforce.Argument(() => reportFileUploader);
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_TestFileLocation = testFileLocation;
            m_ReportFileUploader = reportFileUploader;
            m_Diagnostics = diagnostics;
        }
Beispiel #48
0
        public void NotifyServicesOfStartupCompletion()
        {
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);
            var kernel            = new Mock <IKernel>();
            var service           = new CoreProxy(kernel.Object, systemDiagnostics);

            bool wasInvoked = false;

            service.OnStartupComplete += (s, e) => { wasInvoked = true; };

            service.Start();
            service.NotifyServicesOfStartupCompletion();

            Assert.IsTrue(wasInvoked);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandSetMethodInterceptor"/> class.
        /// </summary>
        /// <param name="transmitCommandInvocation">
        ///     The function used to send the information about the method invocation to the owning endpoint.
        /// </param>
        /// <param name="configuration">The object that stores the configuration for the application.</param>
        /// <param name="systemDiagnostics">The function that is used to log messages.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="transmitCommandInvocation"/> 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="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        protected CommandSetMethodInterceptor(
            SendCommandData transmitCommandInvocation,
            IConfiguration configuration,
            SystemDiagnostics systemDiagnostics)
        {
            {
                Lokad.Enforce.Argument(() => transmitCommandInvocation);
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_TransmitCommandInvocation = transmitCommandInvocation;
            m_Configuration             = configuration;
            m_Diagnostics = systemDiagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NotificationProxyBuilder"/> class.
        /// </summary>
        /// <param name="localEndpoint">The ID number of the local endpoint.</param>
        /// <param name="sendWithoutResponse">
        ///     The function that sends out a message to the given endpoint.
        /// </param>
        /// <param name="systemDiagnostics">The object that provides the diagnostic methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="localEndpoint"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="sendWithoutResponse"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public NotificationProxyBuilder(
            EndpointId localEndpoint,
            SendMessage sendWithoutResponse,
            SystemDiagnostics systemDiagnostics)
        {
            {
                Lokad.Enforce.Argument(() => localEndpoint);
                Lokad.Enforce.Argument(() => sendWithoutResponse);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_Local = localEndpoint;
            m_SendWithoutResponse = sendWithoutResponse;
            m_Diagnostics         = systemDiagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceConnectionHolder"/> class.
        /// </summary>
        /// <param name="channelTemplate">The type of channel, e.g. TCP.</param>
        /// <param name="currentTime">The function that returns the current time.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="channelTemplate"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="currentTime"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public ServiceConnectionHolder(
            IChannelTemplate channelTemplate,
            Func <DateTimeOffset> currentTime,
            SystemDiagnostics systemDiagnostics)
        {
            {
                Lokad.Enforce.Argument(() => channelTemplate);
                Lokad.Enforce.Argument(() => currentTime);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_Template    = channelTemplate;
            m_CurrentTime = currentTime;
            m_Diagnostics = systemDiagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DiscoveryChannelTranslator"/> class.
        /// </summary>
        /// <param name="protocolVersions">
        ///     The collection containing all the versions of the protocol layer.
        /// </param>
        /// <param name="templateBuilder">The function that is used to create the channel template that is used to create WCF channels.</param>
        /// <param name="diagnostics">The object that provides the diagnostics for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="protocolVersions"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="templateBuilder"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public DiscoveryChannelTranslator(
            Version[] protocolVersions,
            Func <ChannelTemplate, IDiscoveryChannelTemplate> templateBuilder,
            SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => protocolVersions);
                Lokad.Enforce.Argument(() => templateBuilder);
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_ProtocolVersions = new SortedSet <Version>(protocolVersions);
            m_TemplateBuilder  = templateBuilder;
            m_Diagnostics      = diagnostics;
        }
Beispiel #53
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageReceivingEndpoint"/> class.
        /// </summary>
        /// <param name="messageConverters">The collection that contains all the message converters.</param>
        /// <param name="systemDiagnostics">The object that provides the diagnostics methods for the system.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="messageConverters"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="systemDiagnostics"/> is <see langword="null" />.
        /// </exception>
        public MessageReceivingEndpoint(
            IEnumerable <IConvertCommunicationMessages> messageConverters,
            SystemDiagnostics systemDiagnostics)
        {
            {
                Lokad.Enforce.Argument(() => messageConverters);
                Lokad.Enforce.Argument(() => systemDiagnostics);
            }

            m_Diagnostics = systemDiagnostics;
            foreach (var converter in messageConverters)
            {
                m_Converters.Add(converter.DataTypeToTranslate, converter);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ProxyCompositionLayer"/> class.
        /// </summary>
        /// <param name="commands">The object that provides the commands for the composition of part groups.</param>
        /// <param name="groupConnector">The object that handles the connection of part groups.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="commands"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="groupConnector"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown when <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public ProxyCompositionLayer(
            ICompositionCommands commands,
            IConnectGroups groupConnector,
            SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => commands);
                Lokad.Enforce.Argument(() => groupConnector);
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_Commands    = commands;
            m_Connector   = groupConnector;
            m_Diagnostics = diagnostics;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="XCopyDeployTestStepProcessor"/> class.
        /// </summary>
        /// <param name="testFileLocation">
        /// The function that takes the name of the test step and returns the full path to the directory containing the files for the 
        /// given test step.
        /// </param>
        /// <param name="reportFileUploader">
        /// The function that is used to upload the report files for the current test step.
        /// </param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <param name="fileSystem">The object that provides access to the file system.</param>
        /// <param name="sectionBuilder">The section builder.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="testFileLocation"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="reportFileUploader"/> 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="fileSystem"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="sectionBuilder"/> is <see langword="null" />.
        /// </exception>
        public XCopyDeployTestStepProcessor(
            RetrieveFileDataForTestStep testFileLocation,
            UploadReportFilesForTestStep reportFileUploader,
            SystemDiagnostics diagnostics,
            IFileSystem fileSystem,
            ITestSectionBuilder sectionBuilder)
            : base(testFileLocation, reportFileUploader, diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => fileSystem);
                Lokad.Enforce.Argument(() => sectionBuilder);
            }

            m_FileSystem = fileSystem;
            m_SectionBuilder = sectionBuilder;
        }
Beispiel #56
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Kernel"/> class.
        /// </summary>
        /// <param name="shutdownAction">The action that should be executed just before shut down.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        public Kernel(Action shutdownAction, SystemDiagnostics diagnostics)
        {
            m_ShutdownAction = shutdownAction;
            m_Diagnostics    = diagnostics;

            // Add our own proxy to the collection of services.
            // Do that in the constructor so that this is always loaded.
            // That means that there is no way to install another CoreProxy that
            // we don't control.
            // This also means that there is only one way to uninstall this service,
            // and that is by getting the reference from the kernel which is only
            // possible if we start poking around in the data structures of the kernel.
            // In other words there shouldn't be any (legal) way of removing the
            // coreproxy object.
            Install(new CoreProxy(this, diagnostics));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationFacade"/> class.
        /// </summary>
        /// <param name="service">
        /// The user interface service that handles the communication with the rest of the system.
        /// </param>
        /// <param name="notificationNames">The object that defines the application level notification names.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="service"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="notificationNames"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        internal ApplicationFacade(IUserInterfaceService service, INotificationNameConstants notificationNames, SystemDiagnostics diagnostics)
        {
            {
                Enforce.Argument(() => service);
            }

            m_Service = service;
            m_Service.RegisterNotification(notificationNames.SystemShuttingDown, HandleApplicationShutdown);

            // Initialize the system information object.
            m_SystemInformation = new SystemInformation(
                () => DateTimeOffset.Now,
                () => new SystemInformationStorage() { StartupTime = DateTimeOffset.Now });

            m_Diagnostics = diagnostics;
        }
        public void ProxyConnectingToMethodWithRetryCount()
        {
            var remoteEndpoint = new EndpointId("other");

            var local      = new EndpointId("local");
            var retryCount = -1;
            var timeout    = TimeSpan.MinValue;
            CommandInvokedMessage         intermediateMsg = null;
            SendMessageAndWaitForResponse sender          = (e, m, r, t) =>
            {
                retryCount = r;
                timeout    = t;

                intermediateMsg = m as CommandInvokedMessage;
                return(Task <ICommunicationMessage> .Factory.StartNew(
                           () => new SuccessMessage(remoteEndpoint, new MessageId()),
                           new CancellationToken(),
                           TaskCreationOptions.None,
                           new CurrentThreadTaskScheduler()));
            };

            var configuration = new Mock <IConfiguration>();
            {
                configuration.Setup(c => c.HasValueFor(It.IsAny <ConfigurationKey>()))
                .Returns(false);
            }

            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            var builder = new CommandProxyBuilder(local, sender, configuration.Object, systemDiagnostics);
            var proxy   = builder.ProxyConnectingTo <InteractionExtensionsTest.IMockCommandSetWithTaskReturn>(remoteEndpoint);

            var result = proxy.MyRetryMethod(10);

            result.Wait();

            Assert.IsTrue(result.IsCompleted);
            Assert.IsFalse(result.IsCanceled);
            Assert.IsFalse(result.IsFaulted);

            Assert.AreEqual(
                CommandId.Create(typeof(InteractionExtensionsTest.IMockCommandSetWithTaskReturn).GetMethod("MyRetryMethod")),
                intermediateMsg.Invocation.Command);
            Assert.AreEqual(0, intermediateMsg.Invocation.Parameters.Length);
            Assert.AreEqual(10, retryCount);
            Assert.AreEqual(TimeSpan.FromMilliseconds(CommunicationConstants.DefaultWaitForResponseTimeoutInMilliSeconds), timeout);
        }
        public void AvailableNotifications()
        {
            var commandHub        = new Mock <ISendCommandsToRemoteEndpoints>();
            var id                = new DatasetId();
            var endpoint          = EndpointIdExtensions.CreateEndpointIdForCurrentProcess();
            var networkId         = NetworkIdentifier.ForLocalMachine();
            var systemDiagnostics = new SystemDiagnostics((p, s) => { }, null);

            var notificationList = new Dictionary <Type, INotificationSet>
            {
                {
                    typeof(IMockNotificationSetWithEventHandler),
                    new Mock <IMockNotificationSetWithEventHandler>().Object
                },
                {
                    typeof(IMockNotificationSetWithTypedEventHandler),
                    new Mock <IMockNotificationSetWithTypedEventHandler>().Object
                },
                {
                    typeof(IMockNotificationSetForInternalUse),
                    new Mock <IMockNotificationSetForInternalUse>().Object
                },
            };

            var datasetNotifications = new Mock <IDatasetApplicationNotifications>();
            var notificationHub      = new Mock <INotifyOfRemoteEndpointEvents>();
            {
                notificationHub.Setup(h => h.AvailableNotificationsFor(It.IsAny <EndpointId>()))
                .Returns(notificationList.Keys);
                notificationHub.Setup(h => h.NotificationsFor(It.IsAny <EndpointId>(), It.IsAny <Type>()))
                .Returns <EndpointId, Type>((e, t) => notificationList[t]);
                notificationHub.Setup(n => n.NotificationsFor <IDatasetApplicationNotifications>(It.IsAny <EndpointId>()))
                .Callback <EndpointId>(e => Assert.AreSame(endpoint, e))
                .Returns(datasetNotifications.Object);
            }

            var info = new DatasetOnlineInformation(
                id,
                endpoint,
                networkId,
                commandHub.Object,
                notificationHub.Object,
                systemDiagnostics);
            var notifications = info.AvailableNotifications();

            Assert.AreEqual(2, notifications.Count());
        }
Beispiel #60
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;
        }