public void Test3() { var serverProperty = BindToServer(LifetimeDefinition.Lifetime, new RdProperty <string> { IsMaster = true }, ourKey); var clientProperty = BindToClient(LifetimeDefinition.Lifetime, new RdProperty <string> { IsMaster = false }, ourKey); // Client -> Server clientProperty.SetValue("Client value 1"); ClientWire.TransmitOneMessage(); // Change server var serverValue1 = "Server value 1"; serverProperty.SetValue(serverValue1); // Client -> Server one more time (server should not be updated) clientProperty.SetValue("Client value 2"); ClientWire.TransmitOneMessage(); // Server -> Client one more time (client should be updated) ServerWire.TransmitOneMessage(); Assert.AreEqual(serverValue1, serverProperty.Value); Assert.AreEqual(serverValue1, clientProperty.Value); }
public void Test5() { var serverProperty = BindToServer(LifetimeDefinition.Lifetime, new RdProperty <string> { IsMaster = true }, ourKey); var clientProperty = BindToClient(LifetimeDefinition.Lifetime, new RdProperty <string> { IsMaster = false }, ourKey); serverProperty.SetValue("Server value 1"); ServerWire.TransmitOneMessage(); clientProperty.SetValue("Client value 1"); ClientWire.TransmitOneMessage(); clientProperty.SetValue("Client value 2"); ClientWire.MissOneMessage(); clientProperty.SetValue("Client value 3"); ClientWire.TransmitOneMessage(); serverProperty.SetValue("Server value 2"); ServerWire.MissOneMessage(); serverProperty.SetValue("Server value 3"); ServerWire.TransmitOneMessage(); Assert.AreEqual("Server value 3", serverProperty.Value); Assert.AreEqual("Server value 3", clientProperty.Value); }
public void Test1() { var serverProperty = BindToServer(LifetimeDefinition.Lifetime, new RdProperty <string> { IsMaster = true }, ourKey); var clientProperty = BindToClient(LifetimeDefinition.Lifetime, new RdProperty <string> { IsMaster = false }, ourKey); // Everything is empty Assert.False(serverProperty.Maybe.HasValue); Assert.False(clientProperty.Maybe.HasValue); // Init server var serverValue1 = "Server value 1"; serverProperty.SetValue(serverValue1); Assert.AreEqual(serverValue1, serverProperty.Value); Assert.False(clientProperty.Maybe.HasValue); // Server -> Client ServerWire.TransmitOneMessage(); Assert.AreEqual(serverValue1, clientProperty.Value); // Client -> Server var clientValue1 = "Client value 1"; clientProperty.SetValue(clientValue1); ClientWire.TransmitOneMessage(); Assert.AreEqual(clientValue1, serverProperty.Value); Assert.AreEqual(clientValue1, clientProperty.Value); }
public void TestLifetimes2() { var serverMap = BindToServer(LifetimeDefinition.Lifetime, new RdMap <int, string> { IsMaster = true, OptimizeNested = true }, ourKey); var clientMap = BindToClient(LifetimeDefinition.Lifetime, new RdMap <int, string> { IsMaster = false, OptimizeNested = true }, ourKey); var itemRemovedServer = false; var itemRemovedClient = false; serverMap.View(Lifetime.Eternal, (lifetime, key, value) => { lifetime.OnTermination(() => { itemRemovedServer = true; }); }); clientMap.View(Lifetime.Eternal, (lifetime, key, value) => { lifetime.OnTermination(() => { itemRemovedClient = true; }); }); serverMap.Add(1, "Server value"); ServerWire.TransmitOneMessage(); clientMap.Remove(1); ClientWire.TransmitOneMessage(); //ack Assert.IsFalse(itemRemovedServer); ClientWire.TransmitOneMessage(); Assert.IsTrue(itemRemovedServer); Assert.IsTrue(itemRemovedClient); }
public void Test1() { var serverList = BindToServer(TestLifetime, new RdList <string> { OptimizeNested = true }, ourKey); var clientList = BindToClient(TestLifetime, new RdList <string> { OptimizeNested = true }, ourKey); Assert.True(serverList.Count == 0); Assert.True(clientList.Count == 0); serverList.Add("Server value 1"); serverList.Add("Server value 2"); serverList.Add("Server value 3"); ServerWire.TransmitOneMessage(); ServerWire.TransmitOneMessage(); ServerWire.TransmitOneMessage(); Assert.AreEqual(3, clientList.Count); serverList.Add("Server value 4"); ServerWire.TransmitOneMessage(); clientList[3] = "Client value 4"; ClientWire.TransmitOneMessage(); Assert.AreEqual("Client value 4", clientList[3]); Assert.AreEqual("Client value 4", serverList[3]); serverList.RemoveAt(0); ServerWire.TransmitOneMessage(); Assert.AreEqual("Server value 2", clientList[0]); Assert.AreEqual("Server value 2", serverList[0]); }
public void TestLifetimes2() { var serverList = BindToServer(LifetimeDefinition.Lifetime, new RdList <string> { OptimizeNested = true }, ourKey); var clientList = BindToClient(LifetimeDefinition.Lifetime, new RdList <string> { OptimizeNested = true }, ourKey); var itemRemovedServer = false; var itemRemovedClient = false; serverList.View(Lifetime.Eternal, (lifetime, key, value) => { lifetime.OnTermination(() => { itemRemovedServer = true; }); }); clientList.View(Lifetime.Eternal, (lifetime, key, value) => { lifetime.OnTermination(() => { itemRemovedClient = true; }); }); serverList.Add("Server value"); ServerWire.TransmitOneMessage(); clientList.RemoveAt(0); Assert.IsFalse(itemRemovedServer); ClientWire.TransmitOneMessage(); Assert.IsTrue(itemRemovedServer); Assert.IsTrue(itemRemovedClient); }
public void TestFireSignal() { var serverSignal = BindToServer(LifetimeDefinition.Lifetime, new RdSignal <string>(), ourKey); var clientSignal = BindToClient(LifetimeDefinition.Lifetime, new RdSignal <string>(), ourKey); var results = new List <string>(); clientSignal.Advise(LifetimeDefinition.Lifetime, value => results.Add(value)); serverSignal.Fire("server value"); ServerWire.TransmitOneMessage(); Assert.AreEqual(1, results.Count); Assert.AreEqual("server value", results[0]); }
public void TestLifetimes1() { var serverMap = BindToServer(LifetimeDefinition.Lifetime, new RdMap <int, string> { IsMaster = true, OptimizeNested = true }, ourKey); var clientMap = BindToClient(LifetimeDefinition.Lifetime, new RdMap <int, string> { IsMaster = false, OptimizeNested = true }, ourKey); var itemRemoved = ""; serverMap.Add(1, "Server value"); serverMap.View(LifetimeDefinition.Lifetime, (lifetime, i, s) => itemRemoved = i + ":" + s); ServerWire.TransmitOneMessage(); clientMap.Remove(1); ClientWire.TransmitAllMessages(); Assert.AreEqual("1:Server value", itemRemoved); }
public void TestLifetimes1() { var serverList = BindToServer(TestLifetime, new RdList <string> { OptimizeNested = true }, ourKey); var clientList = BindToClient(TestLifetime, new RdList <string> { OptimizeNested = true }, ourKey); var itemRemoved = ""; serverList.Add("Server value"); serverList.View(TestLifetime, (lifetime, i, s) => itemRemoved = i + ":" + s); ServerWire.TransmitOneMessage(); clientList.Remove("Server value"); clientList.Remove("Server value"); ClientWire.TransmitAllMessages(); Assert.AreEqual("0:Server value", itemRemoved); }
public void Test1() { var serverMap = BindToServer(LifetimeDefinition.Lifetime, new RdMap <int, string> { IsMaster = true, OptimizeNested = true }, ourKey); var clientMap = BindToClient(LifetimeDefinition.Lifetime, new RdMap <int, string> { IsMaster = false, OptimizeNested = true }, ourKey); Assert.True(serverMap.Count == 0); Assert.True(clientMap.Count == 0); serverMap.Add(1, "Server value 1"); serverMap.Add(2, "Server value 2"); serverMap.Add(3, "Server value 3"); ServerWire.TransmitOneMessage(); ServerWire.TransmitOneMessage(); ServerWire.TransmitOneMessage(); ClientWire.TransmitOneMessage(); //ack ClientWire.TransmitOneMessage(); //ack ClientWire.TransmitOneMessage(); //ack Assert.AreEqual(3, clientMap.Count); serverMap.Add(4, "Server value 4"); clientMap.Add(4, "Client value 4"); ServerWire.TransmitOneMessage(); ClientWire.TransmitOneMessage(); //ack ClientWire.TransmitOneMessage(); Assert.AreEqual("Server value 4", clientMap[4]); Assert.AreEqual("Server value 4", serverMap[4]); serverMap.Add(5, "Server value 5"); clientMap.Add(5, "Client value 5"); ClientWire.TransmitOneMessage(); ServerWire.TransmitOneMessage(); ClientWire.TransmitOneMessage(); //ack Assert.AreEqual("Server value 5", clientMap[5]); Assert.AreEqual("Server value 5", serverMap[5]); }