Exemplo n.º 1
0
        public void TestLateBind02()
        {
            var key = RdContextBasicTest.TestKeyHeavy.Instance;

            var serverMap = new RdPerContextMap <string, RdMap <int, string> >(key, _ => new RdMap <int, string>());
            var clientMap = new RdPerContextMap <string, RdMap <int, string> >(key, _ => new RdMap <int, string>());

            var server1Cid = "Server-1";
            var client1Cid = "Client-1";

            key.RegisterOn(ClientProtocol.Serializers);
            ServerProtocol.Contexts.RegisterContext(key);
            ClientProtocol.Contexts.RegisterContext(key);

            // no protocol value set value - pre-bind value will be lost

            serverMap[server1Cid][1] = "test";

            BindToClient(LifetimeDefinition.Lifetime, clientMap, 1);
            BindToServer(LifetimeDefinition.Lifetime, serverMap, 1);

            Assert.False(clientMap.TryGetValue(server1Cid, out _));

            Assert.False(serverMap.TryGetValue(client1Cid, out _));
        }
Exemplo n.º 2
0
        public void TestLateBind01()
        {
            var key = RdContextBasicTest.TestKeyHeavy.Instance;

            var serverMap = new RdPerContextMap <string, RdMap <int, string> >(key, _ => new RdMap <int, string>());
            var clientMap = new RdPerContextMap <string, RdMap <int, string> >(key, _ => new RdMap <int, string>());

            var server1Cid = "Server-1";
            var client1Cid = "Client-1";

            key.RegisterOn(ClientProtocol.Serializers);
            ServerProtocol.Contexts.RegisterContext(key);
            ClientProtocol.Contexts.RegisterContext(key);

            ServerProtocol.Contexts.GetValueSet(key).Add(server1Cid);

            serverMap[server1Cid][1] = "test";
            ClientProtocol.Contexts.GetValueSet(key).Add(client1Cid);

            BindToClient(LifetimeDefinition.Lifetime, clientMap, 1);
            BindToServer(LifetimeDefinition.Lifetime, serverMap, 1);

            Assert.True(clientMap.TryGetValue(server1Cid, out var map) && map != null);
            Assert.AreEqual("test", clientMap[server1Cid][1]);

            Assert.True(serverMap.TryGetValue(client1Cid, out var map1) && map1 != null);
            Assert.False(serverMap[client1Cid].ContainsKey(1));
        }