Esempio n. 1
0
        public static IMultiService Create(int depth)
        {
            var endpoint = "Multi_" + depth;

            TinyService.Host(new MultiService(depth)).AtEndpoint(endpoint);
            return(TinyClient.Create <IMultiService>(endpoint));
        }
 public static void Run()
 {
     using (TinyService.Host(new Service()).AtEndpoint("test"))
     {
         var client = TinyClient.Create <IService>("test");
         Console.WriteLine(client.Call("1"));
         Console.WriteLine(client.Call(1));
         Console.WriteLine(client.Call(1.0));
     }
 }
Esempio n. 3
0
 public static void Run()
 {
     using (TinyService.Host(new Server()).AtEndpoint("test"))
     {
         var client = TinyClient.Create <IServer>("test");
         client.Register(new Callback());
         client.Raise("x");
         client.Register(new Callback());
         client.Raise("y");
     }
 }
        public void NullablesTest()
        {
            var service = new Mock <INullableTestService>();

            service.Setup(x => x.Test(null)).Returns <double?>(null);
            service.Setup(x => x.Test(1.23)).Returns(1.23);

            using (TinyService.Host(service.Object).AtEndpoint("test"))
            {
                var client = TinyClient.Create <INullableTestService>("test");
                client.Test(null).ShouldBe(null);
                client.Test(1.23).ShouldBe(1.23);
            }
        }
Esempio n. 5
0
        public static void Run()
        {
            var service = new ValueContainer <ValueContainer <string> >();

            service.UpdateValue(new ValueContainer <string>());

            using (TinyService.Host(service).AtEndpoint("test"))
            {
                var client = TinyClient.Create <IValueContainer <IValueContainer <string> > >("test");
                client.Value.UpdateValue("abc");
                client.Value.UpdateValue("cde");
                Console.WriteLine(client.Value.Value);
            }
        }
        public void SetUp()
        {
            var service = new Mock <IRetentionService>();

            service.Setup(x => x.GetInstance(It.IsAny <string>())).Returns <string>(text =>
            {
                var instance = new Mock <IRetentionInstance>();
                instance.Setup(x => x.Call()).Returns(text);
                return(instance.Object);
            });

            endpoint = TinyService.Host(service.Object).WithCleanupInterval(TimeSpan.FromSeconds(2)).AtEndpoint("test");
            client   = TinyClient.Create <IRetentionService>("test");
        }
        public void ShouldThrowIfTimedOut()
        {
            var service = new Mock <INullableTestService>();

            service.Setup(x => x.Test(null)).Returns <double?>(x =>
            {
                Thread.Sleep(2000);
                return(null);
            });

            using (TinyService.Host(service.Object).AtEndpoint("test"))
            {
                TinyClient.InitDefaultEndpoint(executionTimeout: TimeSpan.FromSeconds(1));
                var client = TinyClient.Create <INullableTestService>("test");
                Should.Throw <TimeoutException>(() => client.Test(null));
            }
        }
        public static void Run()
        {
            var service = new ValueContainer <IService> {
                Value = new Service()
            };

            using (TinyService.Host(service).AtEndpoint("test"))
            {
                var client = TinyClient.Create <IValueContainer <IService> >("test");
                var base1  = client.Value.GetNewBase();
                base1.Call();
                var specific1 = TinyClient.CastProxy <ISpecific>(base1);
                specific1.Call();
                specific1.CallSpecific();

                var base2 = client.Value.Base;
                base2.Call();
                var specific2 = TinyClient.CastProxy <ISpecific>(base2);
                specific2.Call();
                specific2.CallSpecific();
            }
        }
Esempio n. 9
0
        public static void Run()
        {
            var service = new ValueContainer <IEnumerable <IValueContainer <int> > >();

            service.UpdateValue(
                new[]
            {
                new ValueContainer <int>(),
                new ValueContainer <int>()
            });

            using (TinyService.Host(service).AtEndpoint("test"))
            {
                var client     = TinyClient.Create <IValueContainer <IEnumerable <IValueContainer <int> > > >("test");
                var containers = client.Value.ToList();
                for (int i = 0; i < containers.Count; ++i)
                {
                    containers[i].UpdateValue(i);
                    Console.WriteLine(service.Value.ElementAt(i).Value);
                    Console.WriteLine(containers[i].Value);
                }
            }
        }
 public void NoServiceTest()
 {
     Should.Throw <TinyWebServiceException>(() => TinyClient.Create <INullableTestService>("test"));
 }