Exemple #1
0
        public void SetUp()
        {
            try
            {
                Tester = new ServiceTester <CalculatorServiceHost>
                {
                    CommunicationKernel = new MicrodotInitializer(
                        "CalculatorServiceCommLayer",
                        new ConsoleLogLoggersModules(),
                        k =>
                    {
                        k.Rebind <ICacheRevoker>().ToConstant(_fakeRevokingManager);
                        k.Rebind <IRevokeListener>().ToConstant(_fakeRevokingManager);
                        k.Rebind <ICertificateLocator>().To <DummyCertificateLocator>().InSingletonScope();
                    }
                        ).Kernel
                };

                Service            = Tester.GetServiceProxy <ICalculatorService>();
                ServiceWithCaching = Tester.GetServiceProxyWithCaching <ICalculatorService>();
                ProxyProvider      = Tester.GetServiceProxyProvider("CalculatorService");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        public void AfterOrleansStartup_ShouldBeCalled()
        {
            var tester = new ServiceTester <TestHost>();

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

            tester.Dispose();
        }
        public void TestFixtureSetUp()
        {
            _serviceTester = new ServiceTester <CalculatorServiceHost>();

            _serviceProxy = _serviceTester.GetServiceProxy <ICalculatorService>();

            _flumeQueue = (SpyEventPublisher)_serviceTester.Host.Kernel.Get <IEventPublisher>();
        }
        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");
        }
Exemple #5
0
        public void FixtureSetup()
        {
            if (!UriParser.IsKnownScheme("pack"))
            {
                new System.Windows.Application();
            }

            this.tester = new ServiceTester <DirectoryWatch>();
        }
 public void SetUp()
 {
     try
     {
         _tester = new ServiceTester <CalculatorServiceHost>();
         _serviceProxyProvider = _tester.GetServiceProxyProvider("CalculatorService");
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
 public void SetUp()
 {
     try
     {
         _tester = AssemblyInitialize.ResolutionRoot.GetServiceTester <CalculatorServiceHost>();
         _serviceProxyProvider = _tester.GetServiceProxyProvider("CalculatorService");
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
        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();
        }
Exemple #9
0
        public async Task CanBindStorage()
        {
            ServiceTester <MemoryServiceHost> selfHostService = new ServiceTester <MemoryServiceHost>();

            var accountGrain = selfHostService.GrainClient.GetGrain <IAccountGrain>(0);
            await accountGrain.Save(new Account()
            {
                Name = "test"
            });

            var accunt = await accountGrain.Get();

            Assert.AreEqual("test", accunt.Name);
        }
Exemple #10
0
        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();
        }
        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");
        }
Exemple #12
0
        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  ---------------");
            }
        }
        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;
        }
Exemple #14
0
        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return(View(ServiceTester.GetSomeDataRandomly()));
        }
 public void SetUp()
 {
     tester = AssemblyInitialize.ResolutionRoot.GetServiceTester <CalculatorServiceHost>();
 }
 public void SetUp()
 {
     _tester = new ServiceTester <CalculatorServiceHost>();
 }