Beispiel #1
0
        public void TestOverloadResolution()
        {
            var svcName = TestUtils.TestName;

            ServerServices.DeployClusterSingleton(svcName, new TestServiceOverloads());
            var svc = Client.GetServices().GetServiceProxy <ITestServiceOverloads>(svcName);

            Assert.AreEqual(true, svc.Foo());
            Assert.AreEqual(1, svc.Foo(default(int)));
            Assert.AreEqual(3, svc.Foo(default(byte)));
            Assert.AreEqual(4, svc.Foo(default(short)));
            Assert.AreEqual(6, svc.Foo(new Person()));
            Assert.AreEqual(8, svc.Foo(new[] { 1 }));
            Assert.AreEqual(9, svc.Foo(new[] { new object() }));

            // Unsigned types are not preserved by the binary protocol and resolve to signed counterparts.
            Assert.AreEqual(1, svc.Foo(default(uint)));
            Assert.AreEqual(4, svc.Foo(default(ushort)));

            if (!_useBinaryArray)
            {
                // Array types are not distinguished.
                Assert.AreEqual(9, svc.Foo(new[] { new Person(0) }));
            }
            else
            {
                Assert.AreEqual(9, svc.Foo(new object[] { new Person(0) }));
                Assert.AreEqual(10, svc.Foo(new[] { new Person(0) }));
                Assert.AreEqual(10, svc.Foo(new Person[] { new Person(0) }));
            }
        }
Beispiel #2
0
 public GiphyModule(ChannelServices channelServices, GiphyApi api, ServerServices serverServices, Server server)
 {
     _channelServices = channelServices;
     _api             = api;
     _serverServices  = serverServices;
     _prefix          = _serverServices.GetGuildPrefix(server.Id).Result;
 }
Beispiel #3
0
        public void TestSitesGet()
        {
            ServerServices services = new ServerServices();

            List <Site> sites = services.GetSites();

            Assert.True(sites.Count > 0);
        }
 public void RemoveServer(string serverId)
 {
     ServerServices.Remove(serverId);
     foreach (var partitionInfo in Partitions)
     {
         partitionInfo.serverIds.Remove(serverId);
     }
 }
Beispiel #5
0
        public void TestGenericMethodCall()
        {
            var svcName = TestUtils.TestName;

            ServerServices.DeployClusterSingleton(svcName, new TestServiceGenericMethods());

            var svc = Client.GetServices().GetServiceProxy <ITestServiceGenericMethods>(svcName);

            Assert.AreEqual("1", svc.GetGeneric("1"));
        }
Beispiel #6
0
        public void TestEmptyClusterGroupThrowsError()
        {
            ServerServices.DeployNodeSingleton(ServiceName, new TestService());

            var clusterGroup = Client.GetCluster().ForPredicate(_ => false);
            var svc          = clusterGroup.GetServices().GetServiceProxy <ITestService>(ServiceName);

            var ex = Assert.Throws <IgniteClientException>(() => svc.VoidMethod());

            Assert.AreEqual("Cluster group is empty", ex.Message);
        }
Beispiel #7
0
 public Form1()
 {
     //TODO: mudar o uri pra receber de algum sitio
     _server = (ServerServices)Activator.GetObject(
         typeof(ServerServices),
         "tcp://localhost:58510/ServerServices");
     InitializeComponent();
     clearForm();
     refreshUserFromServer();
     getUserPosts();
     refreshMyMural();
 }
Beispiel #8
0
        /// <summary>
        /// Deploys test service and returns client-side proxy.
        /// </summary>
        private T DeployAndGetTestService <T>(Func <IServicesClient, IServicesClient> transform = null) where T : class
        {
            ServerServices.DeployClusterSingleton(ServiceName, new TestService());

            var services = Client.GetServices();

            if (transform != null)
            {
                services = transform(services);
            }

            return(services.GetServiceProxy <T>(ServiceName));
        }
Beispiel #9
0
 public CommandHandler(IServiceProvider provider, DiscordSocketClient client,
                       CommandService service, IConfiguration config,
                       ServerServices serverServices, AutoRoleServices autoRoleServices,
                       LavaNode lavaNode,
                       Images images)
 {
     _logger           = provider.GetRequiredService <ILogger <CommandHandler> >();
     _provider         = provider;
     _client           = client;
     _service          = service;
     _config           = config;
     _serverServices   = serverServices;
     _autoRoleServices = autoRoleServices;
     _lavaNode         = lavaNode;
     _images           = images;
 }
Beispiel #10
0
        public void TestServicesWithCustomClusterGroupInvokeOnSpecifiedNodes()
        {
            ServerServices.DeployNodeSingleton(ServiceName, new TestService());

            foreach (var ignite in Ignition.GetAll())
            {
                var node         = ignite.GetCluster().GetLocalNode();
                var clusterGroup = Client.GetCluster().ForPredicate(n => n.Id == node.Id);
                var svc          = clusterGroup.GetServices();

                Assert.AreSame(clusterGroup, svc.ClusterGroup);
                Assert.AreEqual(node.Id, clusterGroup.GetNodes().Single().Id);

                var actualNodeId = svc.GetServiceProxy <ITestService>(ServiceName).GetNodeId();
                Assert.AreEqual(node.Id, actualNodeId);
            }
        }
        public async Task BasicTest()
        {
            await using var serving = await WebSocketHost.ServeAsync();

            var authServer     = ServerServices.GetRequiredService <IServerSideAuthService>();
            var authClient     = ClientServices.GetRequiredService <IAuthService>();
            var sessionFactory = ClientServices.GetRequiredService <ISessionFactory>();
            var sessionA       = sessionFactory.CreateSession();
            var sessionB       = sessionFactory.CreateSession();
            var alice          = new User("Local", "alice", "Alice");
            var bob            = new User("Local", "bob", "Bob");
            var guest          = new User("<guest>");

            var session = sessionA;
            await ServerServices.Commander().CallAsync(new SignInCommand(bob, session).MarkServerSide());

            var user = await authServer.GetUserAsync(session);

            user.Name.Should().Be(bob.Name);

            user = await authClient.GetUserAsync(sessionA);

            user.Name.Should().Be(bob.Name);
            user = await authClient.GetUserAsync(session);

            user.Name.Should().Be(bob.Name);

            session = sessionB;
            user    = await authClient.GetUserAsync(session);

            user.Id.Should().Be(sessionB.Id);
            user.Name.Should().Be(User.GuestName);

            session = sessionFactory.CreateSession();
            user    = await authClient.GetUserAsync(session);

            // User.Id should be equal to new AuthSession.Id
            user.Id.Length.Should().BeGreaterThan(8);
            user.Name.Should().Be(User.GuestName);
        }
Beispiel #12
0
 public ChannelModule(ServerServices serverServices, ChannelServices channelServices)
 {
     _serverServices  = serverServices;
     _channelServices = channelServices;
 }
Beispiel #13
0
        public void TestTearDown()
        {
            ServerServices.CancelAll();

            TestUtils.AssertHandleRegistryIsEmpty(1000, Ignition.GetAll().ToArray());
        }
Beispiel #14
0
        public void TestAllArgumentTypes()
        {
            ServerServices.DeployClusterSingleton(ServiceName, new TestServiceDataTypes());
            var svc = Client.GetServices().GetServiceProxy <ITestServiceDataTypes>(ServiceName);

            Assert.AreEqual(2, svc.GetByte(1));
            Assert.AreEqual(new byte[] { 3, 4, 5 }, svc.GetByteArray(new byte[] { 2, 3, 4 }));

            Assert.AreEqual(3, svc.GetSbyte(2));
            Assert.AreEqual(new sbyte[] { -4, 6 }, svc.GetSbyteArray(new sbyte[] { -5, 5 }));

            Assert.AreEqual(3, svc.GetShort(2));
            Assert.AreEqual(new short[] { -4, 6 }, svc.GetShortArray(new short[] { -5, 5 }));

            Assert.AreEqual(3, svc.GetUShort(2));
            Assert.AreEqual(new ushort[] { 1, 6 }, svc.GetUShortArray(new ushort[] { 0, 5 }));

            Assert.AreEqual(3, svc.GetInt(2));
            Assert.AreEqual(new [] { -4, 6 }, svc.GetIntArray(new[] { -5, 5 }));

            Assert.AreEqual(3, svc.GetUInt(2));
            Assert.AreEqual(new uint[] { 1, 6 }, svc.GetUIntArray(new uint[] { 0, 5 }));

            Assert.AreEqual(long.MaxValue - 9, svc.GetLong(long.MaxValue - 10));
            Assert.AreEqual(new [] { long.MinValue + 1, 6 }, svc.GetLongArray(new[] { long.MinValue, 5 }));

            Assert.AreEqual(ulong.MaxValue - 9, svc.GetULong(ulong.MaxValue - 10));
            Assert.AreEqual(new ulong[] { 1, 10 }, svc.GetULongArray(new ulong[] { 0, 9 }));

            Assert.AreEqual('d', svc.GetChar('c'));
            Assert.AreEqual(new[] { 'b', 'c' }, svc.GetCharArray(new[] { 'a', 'b' }));

            var guid = Guid.NewGuid();

            Assert.AreEqual(guid, svc.GetGuid(guid));
            Assert.AreEqual(new[] { guid, Guid.Empty }, svc.GetGuidArray(new[] { guid, Guid.Empty }));

            var dt = DateTime.Now;

            Assert.AreEqual(dt.AddDays(1), svc.GetDateTime(dt));
            Assert.AreEqual(new[] { dt.AddDays(1), dt.AddDays(2) }, svc.GetDateTimeArray(new[] { dt, dt.AddDays(1) }));
            Assert.AreEqual(new List <DateTime> {
                dt.AddDays(1), dt.AddDays(2)
            },
                            svc.GetDateTimeList(new[] { dt, dt.AddDays(1) }.ToList()));

            var ts       = TimeSpan.FromSeconds(25);
            var minuteTs = TimeSpan.FromMinutes(1);

            Assert.AreEqual(ts.Add(minuteTs), svc.GetTimeSpan(ts));
            Assert.AreEqual(new[] { ts.Add(minuteTs), minuteTs }, svc.GetTimeSpanArray(new[] { ts, TimeSpan.Zero }));

            Assert.AreEqual(true, svc.GetBool(false));
            Assert.AreEqual(new[] { true, false }, svc.GetBoolArray(new[] { false, true }));

            Assert.AreEqual(1.5f, svc.GetFloat(0.5f));
            Assert.AreEqual(new[] { -0.5f, 1.1f }, svc.GetFloatArray(new[] { -1.5f, 0.1f }));

            Assert.AreEqual(1.5d, svc.GetDouble(0.5d));
            Assert.AreEqual(new[] { -7.02d, 1.1d }, svc.GetDoubleArray(new[] { -8.02d, 0.1d }));

            Assert.AreEqual(1.666m, svc.GetDecimal(0.666m));
            Assert.AreEqual(new[] { -7.66m, 1.33m }, svc.GetDecimalArray(new[] { -8.66m, 0.33m }));

            Assert.AreEqual("foo", svc.GetString("FOO"));
            Assert.AreEqual(new[] { "foo", "bar" }, svc.GetStringArray(new[] { "FoO", "bAr" }));
        }
Beispiel #15
0
 public void SetServer(ServerServices server)
 {
     Server = server;
 }
Beispiel #16
0
 public void SetServer(ServerServices server)
 {
     Server = server;
 }
Beispiel #17
0
 public FunModule(ServerServices serverServices)
 {
     _serverServices = serverServices;
 }
 public void AddServer(string serverId, string url)
 {
     ServerServices.Add(serverId, PuppetMaster.urlToNodeService(url));
     ServersUrls.Add(serverId, url);
 }
 public ConfigurationModule(ServerServices serverServices, ChannelServices channelServices, ConfigurationServices configurationServices)
 {
     _serverServices        = serverServices;
     _configurationServices = configurationServices;
     _channelServices       = channelServices;
 }