Пример #1
0
        public void UpdateClientProcedure_ClientArrivalNotificationClientSide_UpdatesUXAboutChanges()
        {
            int dataSize = 10;

            // SessionData After adding new user
            SessionData sData = Utils.GenerateSampleSessionData(dataSize);

            // The new user is removed as it wont be present before joining
            UserData newUser = sData.users[dataSize - 1];

            sData.users.RemoveAt(dataSize - 1);

            // When the old user joins the first time, it would recieve complete session object
            ServerToClientData serverToClientData = new("addClient", sData, null, sData.users[dataSize - 2]);;;

            clientSessionManagerA.OnDataReceived(_serializer.Serialize <ServerToClientData>(serverToClientData));
            oldUX.gotNotified = false;

            // Following are recieved when new user joins for old and new users
            sData.AddUser(newUser);
            ServerToClientData serverToClientDataNew = new("addClient", sData, null, sData.users[dataSize - 1]);
            string             serialisedDataNew     = _serializer.Serialize(serverToClientDataNew);

            //Console.WriteLine("MT: " + serialisedDataNew);
            clientSessionManagerB.OnDataReceived(serialisedDataNew);
            clientSessionManagerA.OnDataReceived(_serializer.Serialize(serverToClientDataNew));
            //while (newUX.gotNotified == false) ;
            //while (oldUX.gotNotified == false) ;
            Assert.NotNull(oldUX.sessionData);
            Assert.NotNull(newUX.sessionData);
            CollectionAssert.AreEqual(sData.users, oldUX.sessionData.users);
            CollectionAssert.AreEqual(sData.users, newUX.sessionData.users);
        }