Ejemplo n.º 1
0
        public void SetUp()
        {
            serverSyncDictionary = new SyncDictionaryIntString();
            clientSyncDictionary = new SyncDictionaryIntString();

            // add some data to the list
            serverSyncDictionary.Add(0, "Hello");
            serverSyncDictionary.Add(1, "World");
            serverSyncDictionary.Add(2, "!");
            SerializeAllTo(serverSyncDictionary, clientSyncDictionary);
        }
        public void ObjectCanBeReusedAfterReset()
        {
            clientSyncDictionary.Reset();

            // make old client the host
            SyncDictionaryIntString hostList    = clientSyncDictionary;
            SyncDictionaryIntString clientList2 = new SyncDictionaryIntString();

            Assert.That(hostList.IsReadOnly, Is.False);

            // Check Add and Sync without errors
            hostList.Add(30, "hello");
            hostList.Add(35, "world");
            SerializeDeltaTo(hostList, clientList2);
        }
Ejemplo n.º 3
0
        public void DirtyTest()
        {
            SyncDictionaryIntString serverList = new SyncDictionaryIntString();
            SyncDictionaryIntString clientList = new SyncDictionaryIntString();

            // nothing to send
            Assert.That(serverList.IsDirty, Is.False);

            // something has changed
            serverList.Add(15, "yay");
            Assert.That(serverList.IsDirty, Is.True);
            SerializeDeltaTo(serverList, clientList);

            // data has been flushed,  should go back to clear
            Assert.That(serverList.IsDirty, Is.False);
        }
Ejemplo n.º 4
0
        public void ReadonlyTest()
        {
            SyncDictionaryIntString serverList = new SyncDictionaryIntString();
            SyncDictionaryIntString clientList = new SyncDictionaryIntString();

            // data has been flushed,  should go back to clear
            Assert.That(clientList.IsReadOnly, Is.False);

            serverList.Add(20, "yay");
            serverList.Add(30, "hello");
            serverList.Add(35, "world");
            SerializeDeltaTo(serverList, clientList);

            // client list should now lock itself,  trying to modify it
            // should produce an InvalidOperationException
            Assert.That(clientList.IsReadOnly, Is.True);
            Assert.Throws <InvalidOperationException>(() => clientList.Add(50, "fail"));
        }