public virtual void SetUp()
        {
            _testinghost = new NonOrleansServiceTester <ConfigurableHost <IDemoService> >();

            //    Metric.Context("Service");
            TracingContext.SetRequestID("1");
        }
 public virtual void SetUp()
 {
     _testinghost    = new NonOrleansServiceTester <TestingHost <IDemoService> >();
     _insecureClient = _testinghost.GetServiceProxy <IDemoService>();
     Metric.ShutdownContext("Service");
     TracingContext.SetRequestID("1");
 }
Beispiel #3
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();
            }
        }
        public void TestFixtureSetUp()
        {
            _serviceTester = new NonOrleansServiceTester <CalculatorServiceHost>();

            _serviceProxy = _serviceTester.GetServiceProxy <ICalculatorService>();

            _flumeQueue = (SpyEventPublisher)_serviceTester.Host.Kernel.Get <IEventPublisher>();
        }
Beispiel #5
0
        public void TestFixtureSetUp()
        {
            _serviceTester = new NonOrleansServiceTester <CalculatorServiceHost>();

            _serviceTester.CommunicationKernel.Rebind <ICertificateLocator>().To <DummyCertificateLocator>();

            _serviceProxy = _serviceTester.GetServiceProxy <ICalculatorService>();

            _flumeQueue = (SpyEventPublisher)_serviceTester.Host.Kernel.Get <IEventPublisher>();
        }
        public async Task CallService_ClientHttpsConfiguration_ShouldSucceed(bool httpsEnabledInClient)
        {
            var testingHost = new NonOrleansServiceTester <SlowServiceHost>();

            if (!httpsEnabledInClient)
            {
                testingHost.CommunicationKernel.DisableHttps();
            }

            var client = testingHost.GetServiceProxy <ISlowService>();
            await client.SimpleSlowMethod(1, 2);
        }
Beispiel #7
0
        public void TestMetricsOnSuccess()
        {
            using (var testinghost = new NonOrleansServiceTester <TestingHost <IDemoService> >())
            {
                testinghost.Host.Instance.Increment(0).Returns((ulong)1);

                var res = testinghost.GetServiceProxy <IDemoService>().Increment(0).Result;
                res.Should().Be(1);

                testinghost.Host.Instance.Received().Increment(0);
                Thread.Sleep(100);
                GetMetricsData(testinghost.Host.ServiceName).AssertEquals(DefaultExpected());
            }
        }
Beispiel #8
0
 public void SetUp()
 {
     try
     {
         var serviceTester = new NonOrleansServiceTester <SlowServiceHost>(
             new ServiceArguments(ServiceStartupMode.CommandLineNonInteractive, basePortOverride: DisposablePort.GetPort().Port));
         serviceTester.CommunicationKernel.Rebind <ICertificateLocator>().To <DummyCertificateLocator>().InSingletonScope();
         Service = serviceTester.GetServiceProxyWithCaching <ISlowService>();
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
         throw;
     }
 }
Beispiel #9
0
        public async Task ShouldCallSelfHostServcie()
        {
            NonOrleansServiceTester <CalculatorServiceHost> serviceTester = null;
            var testingKernel = new TestingKernel <TraceLog>();

            try
            {
                serviceTester = testingKernel.GetServiceTesterForNonOrleansService <CalculatorServiceHost>(1111, TimeSpan.FromSeconds(10));
                (await serviceTester.GetServiceProxy <ICalculatorService>().Add(1, 2)).ShouldBe(3);
            }
            finally
            {
                serviceTester?.Dispose();
                testingKernel.Dispose();
            }
        }
        public void TestFixtureSetUp()
        {
            //Environment.SetEnvironmentVariable("ZONE", "zone");
            //Environment.SetEnvironmentVariable("ENV", "env");

            var config = new HostEnvironment(new TestHostEnvironmentSource(
                                                 zone: "zone",
                                                 deploymentEnvironment: "env",
                                                 appName: "ICalculatorService"));

            _serviceTester = new NonOrleansServiceTester <CalculatorServiceHost>();

            _serviceTester.CommunicationKernel.Rebind <ICertificateLocator>().To <DummyCertificateLocator>();

            _serviceProxy = _serviceTester.GetServiceProxy <ICalculatorService>();

            _flumeQueue = (SpyEventPublisher)_serviceTester.Host.Kernel.Get <IEventPublisher>();
        }
Beispiel #11
0
        public void TestMetricsOnFailure()
        {
            using (var testinghost = new NonOrleansServiceTester <TestingHost <IDemoService> >())
            {
                testinghost.Host.Instance.When(a => a.DoSomething()).Do(x => { throw new Exception("Do exception"); });

                Assert.Throws <RemoteServiceException>(() => testinghost.GetServiceProxy <IDemoService>().DoSomething().GetAwaiter().GetResult());

                var metricsExpected = DefaultExpected();

                metricsExpected.Counters = new List <MetricDataEquatable>
                {
                    new MetricDataEquatable {
                        Name = "Failed", Unit = Unit.Calls
                    }
                };

                GetMetricsData(testinghost.Host.ServiceName).AssertEquals(metricsExpected);
            }
        }