示例#1
0
 public void ThenTheServerShouldHaveClients(ushort serverID, int numberOfClients)
 {
     WaitUtility.WaitUntil("Expected server " + serverID + " to have " + numberOfClients + " clients connected.", () =>
     {
         Assert.AreEqual(numberOfClients, world.GetServer(serverID).ClientManager.Count);
     });
 }
        public void ThenAllMessagesAreAccountedFor()
        {
            WaitUtility.WaitUntil("Not all messages received by the server in the given time.",
                                  () => Assert.AreEqual(0, expectedToServer.Except(messagesToServer).Count()),
                                  TimeSpan.FromMinutes(1));
            WaitUtility.WaitUntil("Not all messages received by the clients in the given time.",
                                  () => Assert.AreEqual(0, expectedToClients.Except(messagesToClients).Count()),
                                  TimeSpan.FromMinutes(1));

            Assert.AreEqual(0, messagesToServer.Except(expectedToServer).Count(), "Additional, unexpected messages received by the server.");
            Assert.AreEqual(0, messagesToClients.Except(expectedToClients).Count(), "Additional, unexpected messages received by the clients.");
        }
示例#3
0
        public void ThenServerShouldSynchroniseToHaveServersInGroup(ushort serverID, ushort numberOfServers, string group)
        {
            // 30 second wait as we only update every 10
            WaitUtility.WaitUntil("Incorrect number of servers present in group " + group + ".", () =>
            {
                Assert.AreEqual(numberOfServers, world.GetServer(serverID).RemoteServerManager.GetGroup(group).Count);
            }, TimeSpan.FromSeconds(30));

            WaitUtility.WaitUntil("Servers in group " + group + " are not all connected.", () =>
            {
                Assert.IsTrue(
                    world.GetServer(serverID)
                    .RemoteServerManager.GetGroup(group)
                    .GetAllRemoteServers()
                    .All(s => s.ConnectionState == ConnectionState.Connected)
                    );
            });
        }
        /// <summary>
        ///     Asserts that all objects that were allowedUnaccountedFor from the <see cref="ObjectCache"/> were returned.
        /// </summary>
        private void AssertNoRecyclingIssues()
        {
#if DEBUG
            WaitUtility.WaitUntil("Objects unacounted for.", () => {
                //Check each metric
                int readers = ObjectCacheTestHelper.RetrievedDarkRiftReaders - ObjectCacheTestHelper.ReturnedDarkRiftReaders;
                if (readers != ExpectedUnaccountedForDarkRiftReaders)
                {
                    Assert.Fail(readers + " DarkRiftReader objects are unaccounted for. Expected only " + ExpectedUnaccountedForDarkRiftReaders + ".");
                }

                int writers = ObjectCacheTestHelper.ReturnedDarkRiftWriters - ObjectCacheTestHelper.ReturnedDarkRiftWriters;
                if (writers != ExpectedUnaccountedForDarkRiftWriters)
                {
                    Assert.Fail(writers + " DarkRiftWriter objects are unaccounted for. Expected only " + ExpectedUnaccountedForDarkRiftWriters + ".");
                }

                int messages = ObjectCacheTestHelper.ReturnedMessages - ObjectCacheTestHelper.ReturnedMessages;
                if (messages != ExpectedUnaccountedForMessages)
                {
                    Assert.Fail(messages + " Message objects are unaccounted for. Expected only " + ExpectedUnaccountedForMessages + ".");
                }

                int messageBuffers = ObjectCacheTestHelper.ReturnedMessageBuffers - ObjectCacheTestHelper.ReturnedMessageBuffers;
                if (messageBuffers != ExpectedUnaccountedForMessageBuffers)
                {
                    Assert.Fail(messageBuffers + " MessageBuffer objects are unaccounted for. Expected only " + ExpectedUnaccountedForMessageBuffers + ".");
                }

                int actionDispatcherTasks = ObjectCacheTestHelper.ReturnedActionDispatcherTasks - ObjectCacheTestHelper.ReturnedActionDispatcherTasks;
                if (actionDispatcherTasks != ExpectedUnaccountedForActionDispatcherTasks)
                {
                    Assert.Fail(actionDispatcherTasks + " ActionDispatcherTask objects are unaccounted for. Expected only " + ExpectedUnaccountedForActionDispatcherTasks + ".");
                }

                int autoRecyclingArrays = ObjectCacheTestHelper.ReturnedAutoRecyclingArrays - ObjectCacheTestHelper.ReturnedAutoRecyclingArrays;
                if (autoRecyclingArrays != ExpectedUnaccountedForAutoRecyclingArrays)
                {
                    Assert.Fail(autoRecyclingArrays + " AutoRecyclingArray objects are unaccounted for. Expected only " + ExpectedUnaccountedForAutoRecyclingArrays + ".");
                }

                int socketAsyncEventArgs = ObjectCacheTestHelper.RetrievedSocketAsyncEventArgs - ObjectCacheTestHelper.ReturnedSocketAsyncEventArgs;
                if (socketAsyncEventArgs != ExpectedUnaccountedForSocketAsyncEventArgs)
                {
                    Assert.Fail(socketAsyncEventArgs + " SocketAsyncEventArgs objects are unaccounted for. Expected only " + ExpectedUnaccountedForSocketAsyncEventArgs + ".");
                }

                int serverMessageReceivedEventArgs = ServerObjectCacheTestHelper.RetrievedMessageReceivedEventArgs - ServerObjectCacheTestHelper.ReturnedMessageReceivedEventArgs;
                if (serverMessageReceivedEventArgs != ExpectedUnaccountedForServerMessageReceviedEventArgs)
                {
                    Assert.Fail(serverMessageReceivedEventArgs + " MessageReceivedEventArgs (server) objects are unaccounted for. Expected only " + ExpectedUnaccountedForServerMessageReceviedEventArgs + ".");
                }

                int serverServerMessageReceivedEventArgs = ServerObjectCacheTestHelper.RetrievedServerMessageReceivedEventArgs - ServerObjectCacheTestHelper.ReturnedServerMessageReceivedEventArgs;
                if (serverServerMessageReceivedEventArgs != ExpectedUnaccountedForServerMessageReceviedEventArgs)
                {
                    Assert.Fail(serverServerMessageReceivedEventArgs + " ServerMessageReceivedEventArgs (server) objects are unaccounted for. Expected only " + ExpectedUnaccountedForServerServerMessageReceviedEventArgs + ".");
                }

                int clientMessageReceivedEventArgs = ClientObjectCacheTestHelper.RetrievedMessageReceivedEventArgs - ClientObjectCacheTestHelper.ReturnedMessageReceivedEventArgs;
                if (clientMessageReceivedEventArgs != ExpectedUnaccountedForClientMessageReceviedEventArgs)
                {
                    Assert.Fail(clientMessageReceivedEventArgs + " MessageReceivedEventArgs (client) objects are unaccounted for. Expected only " + ExpectedUnaccountedForClientMessageReceviedEventArgs + ".");
                }

                int memory = ObjectCacheTestHelper.ReturnedMemory - ObjectCacheTestHelper.ReturnedMemory;
                if (memory != ExpectedUnaccountedForMemory)
                {
                    Assert.Fail(memory + " memory segments are unaccounted for. Expected only " + ExpectedUnaccountedForMemory + ".");
                }
            });
#endif
        }
 public void WhenTheServerHasReceivedMessage(ushort server, int numberOfMessages)
 {
     WaitUtility.WaitUntil($"Not enough messages were received on the server within the time limit. Expected as least <{numberOfMessages}> Actual <{messagesToServer.Where(m => m.Destination == server).Count()}>",
                           () => messagesToServer.Where(m => m.Destination == server).Count() >= numberOfMessages);
 }
 public void WhenTheClientHasReceivedMessages(ushort client, int numberOfMessages)
 {
     WaitUtility.WaitUntil($"Not enough messages were received on the client within the time limit. Expected at least <{numberOfMessages}> Actual <{messagesToClients.Where(m => m.Source == client).Count()}>",
                           () => messagesToClients.Where(m => m.Destination == client).Count() >= numberOfMessages);
 }