コード例 #1
0
        public async Task WorkloadMetricsCalledOnce()
        {
            var args = new ServiceArguments(ServiceStartupMode.CommandLineNonInteractive,
                                            ConsoleOutputMode.Disabled,
                                            SiloClusterMode.PrimaryNode,
                                            DisposablePort.GetPort().Port, initTimeOutSec: 10);
            IWorkloadMetrics workloadMetricsFake = Substitute.For <IWorkloadMetrics>();


            var srvHost =
                new ServiceHostFake <IWorkloadMetrics>(
                    workloadMetricsFake,
                    new HostEnvironment(new TestHostEnvironmentSource()))
            {
                FailServiceStartOnConfigError = false
            };;

            Task.Run(() => srvHost.Run(args));
            await srvHost.WaitForServiceStartedAsync();

            srvHost.Dispose();

            workloadMetricsFake.Received(1).Init();
            workloadMetricsFake.Received().Dispose();
        }
コード例 #2
0
        public async Task ValidatorCalledOnce()
        {
            IValidator validatorFake             = Substitute.For <IValidator>();
            ServiceHostFake <IValidator> srvHost = new ServiceHostFake <IValidator>(validatorFake);
            var args = new ServiceArguments(ServiceStartupMode.CommandLineNonInteractive,
                                            ConsoleOutputMode.Disabled,
                                            SiloClusterMode.PrimaryNode,
                                            DisposablePort.GetPort().Port, initTimeOutSec: 10);

            Task.Run(() => srvHost.Run(args));

            await srvHost.WaitForServiceStartedAsync();

            srvHost.Dispose();

            validatorFake.Received(1).Validate();
        }