コード例 #1
0
ファイル: ServiceTesterTests.cs プロジェクト: zhrjin/microdot
        public async Task ServiceTesterWhenServiceFailedToGracefullyShutdownShouldThrow()
        {
            _tester = AssemblyInitialize.ResolutionRoot.GetServiceTester <CalculatorServiceHost>(8555, shutdownWaitTime: TimeSpan.Zero);

            Action act = () => _tester.Dispose();

            act.ShouldThrow <Exception>().Message.ShouldContain("service failed to shutdown gracefully");
        }
コード例 #2
0
        public void AfterOrleansStartup_ShouldBeCalled()
        {
            var tester = new ServiceTester <TestHost>();

            Assert.IsTrue(tester.Host.AfterOrleansCalled, "AfterOrleansStartup hasn't been called.");

            tester.Dispose();
        }
コード例 #3
0
ファイル: WarmupTests.cs プロジェクト: yangchongyuan/microdot
        public async Task InstanceReadyBeforeCallingMethod_Warmup()
        {
            ServiceTester <WarmupTestServiceHostWithSiloHostFake> tester = new ServiceTester <WarmupTestServiceHostWithSiloHostFake>();
            var beforeGrainCreated = DateTime.Now;

            IWarmupTestServiceGrain grain = tester.GrainClient.GetGrain <IWarmupTestServiceGrain>(0);

            var dependencyCreateDate = await grain.DependencyCreateDate();

            Assert.Greater(beforeGrainCreated, dependencyCreateDate, "dependencyCreateDate should create before grain is created");

            tester.Dispose();
        }
コード例 #4
0
ファイル: WarmupTests.cs プロジェクト: zhrjin/microdot
        public async Task InstanceReadyBeforeCallingMethod_Warmup()
        {
            ServiceTester <CalculatorServiceHost> tester = AssemblyInitialize.ResolutionRoot.GetServiceTester <CalculatorServiceHost>(mainPort);

            IWarmupTestServiceGrain grain = tester.GetGrainClient <IWarmupTestServiceGrain>(0);
            int result = await grain.TestWarmedTimes();

            result = await grain.TestWarmedTimes();

            result = await grain.TestWarmedTimes();

            Assert.AreEqual(result, 1);

            tester.Dispose();
        }
コード例 #5
0
        public async Task ServiceTesterWhenServiceFailedToGracefullyShutdownShouldThrow()
        {
            // shutdownWaitTimeSec: 0
            var serviceArguments = new ServiceArguments(
                ServiceStartupMode.CommandLineNonInteractive,
                ConsoleOutputMode.Disabled,
                SiloClusterMode.PrimaryNode,
                DisposablePort.GetPort().Port,
                onStopWaitTimeSec: 0);

            _tester = new ServiceTester <CalculatorServiceHost>(serviceArguments);

            Action act = () => _tester.Dispose();

            act.ShouldThrow <Exception>().Message.ShouldContain("service failed to shutdown gracefully");
        }
コード例 #6
0
ファイル: HostTests.cs プロジェクト: zxw-ing/microdot
        public void HostShouldStartAndStopMultipleTimes()
        {
            _counter++;
            Stopwatch sw = Stopwatch.StartNew();

            Console.WriteLine($"-----------------------------Start run {_counter} time---------------");
            try
            {
                var host = new ServiceTester <TestHost>();
                host.GetServiceProxy <ICalculatorService>();
                Console.WriteLine($"-----------------------------Silo Is running {_counter} time took, {sw.ElapsedMilliseconds}ms---------------");
                host.Dispose();
            }
            finally
            {
                Console.WriteLine(
                    $"-----------------------------End run {_counter} time, took {sw.ElapsedMilliseconds}ms  ---------------");
            }
        }
コード例 #7
0
        public async Task HealthCheck_ServcieDrain_StatueShouldBe521()
        {
            int port = DisposablePort.GetPort().Port;

            //serviceDrainTimeSec:
            var serviceArguments = new ServiceArguments(ServiceStartupMode.CommandLineNonInteractive,
                                                        ConsoleOutputMode.Disabled,
                                                        SiloClusterMode.PrimaryNode, port, serviceDrainTimeSec: 1, instanceName: "test", initTimeOutSec: 10);

            var customServiceTester = new ServiceTester <CalculatorServiceHost>(serviceArguments);

            var dispose = Task.Run(() => customServiceTester.Dispose());
            await Task.Delay(200);

            var httpResponseMessage = await new HttpClient().GetAsync(new Uri($"http://{CurrentApplicationInfo.HostName}:{port}/{nameof(IProgrammableHealth).Substring(1)}.status"));

            httpResponseMessage.StatusCode.ShouldBe((HttpStatusCode)521);
            await dispose;
        }
コード例 #8
0
 public void TestFixtureTearDown()
 {
     _serviceTester?.Dispose();
 }
コード例 #9
0
 public void TearDown()
 {
     tester.Dispose();
 }