Ejemplo n.º 1
0
        public async Task RunInConfigurationVerification_ShouldWriteResults()
        {
            NonOrleansServiceTester <CalculatorServiceHost> serviceTester = null;
            var testingKernel = new TestingKernel <ConsoleLog>();

            try
            {
                var buffer = new StringBuilder();
                var prOut  = Console.Out;
                Console.SetOut(new StringWriter(buffer));

                serviceTester = testingKernel.GetServiceTesterForNonOrleansService <CalculatorServiceHost>(
                    1112,
                    TimeSpan.FromSeconds(10),
                    ServiceStartupMode.VerifyConfigurations);

                var canaryType = typeof(MetricsConfiguration);

                Console.SetOut(prOut);

                Regex.IsMatch(buffer.ToString(), $"(OK|ERROR).*{canaryType.FullName}")
                .ShouldBeTrue("Output should contain a row with validation of the type");

                Console.WriteLine(buffer);
            }
            finally
            {
                Should.Throw <InvalidOperationException>(() => serviceTester?.Dispose())
                .Message.ShouldContain("Service is already stopped");
                testingKernel.Dispose();
            }
        }
Ejemplo n.º 2
0
        public async Task ShouldCallSelfHostServcie()
        {
            var testingKernel = new TestingKernel <TraceLog>();
            var serviceTester = testingKernel.GetServiceTesterForNonOrleansService <CalculatorServiceHost>(1111, TimeSpan.FromSeconds(10));

            (await serviceTester.GetServiceProxy <ICalculatorService>().Add(1, 2)).ShouldBe(3);
            serviceTester.Dispose();
        }