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();
        }
Example #2
0
        public async Task WorkloadMetricsCalledOnce()
        {
            IWorkloadMetrics workloadMetricsFake       = Substitute.For <IWorkloadMetrics>();
            ServiceHostFake <IWorkloadMetrics> srvHost = new ServiceHostFake <IWorkloadMetrics>(workloadMetricsFake);

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

            await srvHost.WaitForHostInitialized();

            await srvHost.StopHost();

            workloadMetricsFake.Received(1).Init();
            workloadMetricsFake.Received().Dispose();
        }