Exemplo n.º 1
0
        private async Task TestHiveValueReplication <T>(string key, T value) where T : struct
        {
            List <ChromeSession> sessions = await chrome.CreateHiveSessions(2);

            try
            {
                var result   = await sessions[0].hiveSetValue(key, value);
                var received = await sessions[1].hiveWaitUntilGetValue <T>(key, 5000);
                //check if what returned from both the set and the get are the same.
                Assert.AreEqual(result, received, key + ": The value was not present on the second session!");
                //cleanup?
                await sessions[0].hiveRemove(key);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                foreach (var item in sessions)
                {
                    item.Dispose();
                }
            }
        }
        public async Task ObjectSyncTest()
        {
            List <ChromeSession> sessions = await chrome.CreateHiveSessions(2);

            var   p = new Point(10, 20);
            await sessions[0].hiveSet("obj1", p);
            await sessions[1].hiveWaitUntilGet("obj1", 5000);

            Assert.IsTrue(await sessions[1].EvalValue <bool>("var p = hive.get(\"obj1\"); p.x ==10 &&p.y==20;"), "the object was not correctly replicated");
        }