public static void Main(string[] args) { InitializeLogging(); Console.Title = "Surface"; var ryu = new RyuFactory().Create(); ((RyuContainerImpl)ryu).Setup(true); const int kPort = 21337; var courierClientFactory = ryu.Get <CourierClientFactory>(); var courierClient = courierClientFactory.CreateUdpCourierClient(kPort, new CourierClientConfiguration { Identifier = Guid.NewGuid() }); int counter = 0; while (true) { var state = GetGamePadState(counter++); Console.WriteLine("Sending state: " + state); courierClient.SendBroadcast(state); Thread.Sleep(70); } }
public void Run() { var ryu = new RyuFactory().Create(); ryu.Setup(); var serviceClientFactory = ryu.Get <ServiceClientFactory>(); var serverServiceClient = serviceClientFactory.Local(kTestServicePort, ClusteringRole.HostOnly); serverServiceClient.RegisterService(new ExampleImplementation(), typeof(ExampleInterface)); var clientServiceClient = serviceClientFactory.Local(kTestServicePort, ClusteringRole.GuestOnly); var remoteService = clientServiceClient.GetService <ExampleInterface>(); var sw = new Stopwatch(); for (var i = 0; i < 10; i++) { sw.Restart(); Guid accountId; AssertTrue(remoteService.TryAuthenticate("warty", "asdf", out accountId)); AssertEquals(kWartyAccountId, accountId); AssertTrue(remoteService.TryAuthenticate("fred", "qwerty", out accountId)); AssertEquals(kFredAccountId, accountId); AssertFalse(remoteService.TryAuthenticate("larry", "zxcv", out accountId)); AssertEquals(Guid.Empty, accountId); Debug.WriteLine("Three queries performed in: " + sw.ElapsedMilliseconds); } }
public void Run() { var ryu = new RyuFactory().Create(); ryu.Setup(); AssertTrue(ryu.Get <PofStreamsFactory>() is PofStreamsFactoryImpl); }
public void Run() { ZileanApplicationEgg.InitializeLogging(); var serverHatchling = new ZileanApplicationEgg(); serverHatchling.Start(null); var systemState = CreateMock <SystemState>(); var managementServer = CreateMock <ILocalManagementServer>(); var clientRyu = new RyuFactory().Create(); clientRyu.Set(systemState); clientRyu.Set(managementServer); clientRyu.Touch <ItzWartyProxiesRyuPackage>(); clientRyu.Touch <ServicesRyuPackage>(); clientRyu.Touch <ZileanClientApiRyuPackage>(); var chronokeeper = clientRyu.Get <ChronokeeperService>(); Debug.WriteLine("Got sequential id: " + chronokeeper.GenerateSequentialId()); Debug.WriteLine("Got sequential guid: " + chronokeeper.GenerateSequentialGuid()); serverHatchling.Shutdown(); }
public void Run() { var ryu = new RyuFactory().Create(); ryu.Touch <ItzWartyCommonsRyuPackage>(); ryu.Setup(); AssertTrue(ryu.Get <ICollectionFactory>() is CollectionFactory); AssertTrue(ryu.Get <ObjectPoolFactory>() is DefaultObjectPoolFactory); }
public void Run() { Console.WriteLine(typeof(ServiceClient).FullName); var ryu = new RyuFactory().Create(); ryu.Setup(); // var clusteringConfiguration = CreateMock<IClusteringConfiguration>(); // ryu.Set<IClusteringConfiguration>(clusteringConfiguration); // var serviceClient = ryu.Get<IServiceClient>(); // AssertNotNull(serviceClient); }
public static void Main(string[] args) { InitializeLogging(); var ryu = new RyuFactory().Create(); ((RyuContainerImpl)ryu).Setup(true); const int kPort = 21337; var courierClientFactory = ryu.Get <CourierClientFactory>(); var courierClient = courierClientFactory.CreateUdpCourierClient(kPort, new CourierClientConfiguration { Identifier = Guid.NewGuid() }); courierClient.RegisterPayloadHandler <GamePadStateDto>(HandleGamePadState); new ManualResetEvent(false).WaitOne(); }
public void Run() { var ryu = new RyuFactory().Create(); ryu.Setup(); var serviceClientFactory = ryu.Get <ServiceClientFactory>(); var serverServiceClient = serviceClientFactory.Local(kTestServicePort, ClusteringRole.HostOnly); var dependency = CreateMock <WrapperClass <int, string> .Dependency <bool> >(); serverServiceClient.RegisterService(new WrapperClass <int, string> .BoxServiceImpl <bool>(dependency), typeof(WrapperClass <int, string> .BoxService <bool>)); var clientServiceClient = serviceClientFactory.Local(kTestServicePort, ClusteringRole.GuestOnly); var remoteService = clientServiceClient.GetService <WrapperClass <int, string> .BoxService <bool> >(); remoteService.Put(10, "hello", true, 123); remoteService.Put(10, "hello", true, true); Verify(dependency, Once()).Touch(10, "hello", true, 123); Verify(dependency, Once(), AfterPrevious()).Touch(10, "hello", true, true); }
public void Run() { var implementation = CreateMock <TestInterface>(); var ryu = new RyuFactory().Create(); ryu.Setup(); ryu.Get <IPofContext>().RegisterPortableObjectType(1337, typeof(AlternateException)); var serviceClientFactory = ryu.Get <ServiceClientFactory>(); var serverServiceClient = serviceClientFactory.Local(kTestServicePort, ClusteringRole.HostOnly); serverServiceClient.RegisterService(implementation, typeof(TestInterface)); var clientServiceClient = serviceClientFactory.Local(kTestServicePort, ClusteringRole.GuestOnly); var remoteService = clientServiceClient.GetService <TestInterface>(); When(implementation.Exec()).ThenReturn(3).ThenThrow(new InvalidOperationException()).ThenThrow(new AlternateException("It broke!")); AssertEquals(3, remoteService.Exec()); AssertThrows <PortableException>(() => remoteService.Exec()); AssertThrows <AlternateException>(() => remoteService.Exec()); }
public void Run() { var ryu = new RyuFactory().Create(); ryu.Setup(); var serviceClientFactory = ryu.Get <ServiceClientFactory>(); var serverServiceClient = serviceClientFactory.Local(kTestServicePort, ClusteringRole.HostOnly); serverServiceClient.RegisterService(new ExampleImplementation(), typeof(ExampleInterface)); var clientServiceClient = serviceClientFactory.Local(kTestServicePort, ClusteringRole.GuestOnly); var remoteService = clientServiceClient.GetService <ExampleInterface>(); const string kValueA = "A"; const string kValueB = "B"; string a = kValueA, b = kValueB; var sw = new Stopwatch(); for (var i = 0; i < 10; i++) { sw.Restart(); remoteService.Swap(ref a, ref b); AssertEquals(kValueB, a); AssertEquals(kValueA, b); remoteService.Swap(ref a, ref b); AssertEquals(kValueA, a); AssertEquals(kValueB, b); Debug.WriteLine("Two swaps performed in: " + sw.ElapsedMilliseconds); } }
public void Run() { const string kExpectedResult = "Hello, Fred who is 8 and not 27... Here's two trues: True True!"; var ryu = new RyuFactory().Create(); ryu.Setup(); var serviceClientFactory = ryu.Get <ServiceClientFactory>(); var serverServiceClient = serviceClientFactory.Local(kTestServicePort, ClusteringRole.HostOnly); serverServiceClient.RegisterService(new ExampleImplementation(), typeof(ExampleInterface)); var clientServiceClient = serviceClientFactory.Local(kTestServicePort, ClusteringRole.GuestOnly); var remoteService = clientServiceClient.GetService <ExampleInterface>(); var echoName = "Fred"; var incorrectAgesIndex = new int[] { 23, 0 }; var incorrectAges = new int[] { 27 }; var one = 1; var oneTwoThreeBoxBox = new Tuple <IntBox>(new IntBox()); int twoThreeFour = -1; var stopwatch = new Stopwatch(); for (var i = 0; i < 5; i++) { stopwatch.Restart(); var easyTask = Async(() => remoteService.Greet("Fred", 8, 27, true, true)); var easyResult = easyTask.Result; Trace.WriteLine($"Easy async invocation #{i} took {stopwatch.ElapsedMilliseconds} ms!"); AssertEquals(kExpectedResult, easyResult); } for (var i = 0; i < 5; i++) { stopwatch.Restart(); var doubleServiceTask = Async(() => remoteService.Greet(echoName, (int)Math.Pow(one + int.Parse("1"), remoteService.Three), 27, true, true)); var doubleServiceResult = doubleServiceTask.Result; Trace.WriteLine($"Double service async invocation ${i} took {stopwatch.ElapsedMilliseconds} ms!"); AssertEquals(kExpectedResult, doubleServiceResult); } for (var i = 0; i < 5; i++) { stopwatch.Restart(); var mediumTask = Async(() => remoteService.Greet(echoName, (int)Math.Pow(one + int.Parse("1"), 3), 27, int.TryParse("123", out oneTwoThreeBoxBox.Item1.value), int.TryParse("234", out twoThreeFour))); var mediumResult = mediumTask.Result; Trace.WriteLine($"Medium async invocation #{i} took {stopwatch.ElapsedMilliseconds} ms!"); AssertEquals(kExpectedResult, mediumResult); AssertEquals(123, oneTwoThreeBoxBox.Item1.value); AssertEquals(234, twoThreeFour); } for (var i = 0; i < 5; i++) { stopwatch.Restart(); var hardTask = Async(() => remoteService.Greet(echoName, (int)Math.Pow(one + int.Parse("1"), remoteService.Three), incorrectAges[incorrectAgesIndex[1]], int.TryParse("123", out oneTwoThreeBoxBox.Item1.value), int.TryParse("234", out twoThreeFour))); var hardResult = hardTask.Result; Trace.WriteLine($"Hard async invocation #{i} took {stopwatch.ElapsedMilliseconds} ms!"); AssertEquals(kExpectedResult, hardResult); AssertEquals(123, oneTwoThreeBoxBox.Item1.value); AssertEquals(234, twoThreeFour); } for (var i = 0; i < 5; i++) { stopwatch.Restart(); Async(() => remoteService.DoNothing()).Wait(); Trace.WriteLine($"No-op invocation #{i} took {stopwatch.ElapsedMilliseconds} ms!"); } for (var i = 0; i < 5; i++) { stopwatch.Restart(); string iOut = null; Async(() => remoteService.OutTest(i, out iOut)).Wait(); AssertEquals(i + "!", iOut); Trace.WriteLine($"Out invocation #{i} took {stopwatch.ElapsedMilliseconds} ms!"); } for (var i = 0; i < 5; i++) { stopwatch.Restart(); string a = "a", b = "b"; Async(() => remoteService.Swap(ref a, ref b)).Wait(); AssertEquals("b", a); AssertEquals("a", b); Trace.WriteLine($"Ref swap invocation #{i} took {stopwatch.ElapsedMilliseconds} ms!"); } }