public void Returns1ForFirstCall() { var target = new ClientStatistic(); target.IncreaseRequestCount(); Assert.AreEqual(1, target.RequestsPerSecond); }
public void InitializesDateTimeProperties() { var target = new ClientStatistic(); var expected = DateTime.UtcNow.ToString("s"); Assert.AreEqual(expected, target.FirstRequest.ToString("s")); Assert.AreEqual(expected, target.LastRequest.ToString("s")); }
public async Task Returns1ForTwoCallsInTwoSeconds() { var target = new ClientStatistic(); target.IncreaseRequestCount(); await Task.Delay(1100); target.IncreaseRequestCount(); Assert.AreEqual(1, target.RequestsPerSecond); }
private Task <ClientStatistic> RunStatisticsClient(object state, MessageControlFlags qos) { var task = new Task <ClientStatistic>(() => { uint clientId = (uint)state; CliClient client = new CliClient(); AVector3 location = new AVector3 { X = clientId * Locator.AREASIZE, Y = clientId * Locator.AREASIZE, Z = clientId * Locator.AREASIZE, }; client.Connect(Host, Port, 0, TokenSigningKey, clientId, location); AutoResetEvent eventFinished = new AutoResetEvent(false); var statistics = new ClientStatistic(); statistics.ClientId = clientId; client.ReliableMessaging.OnDeadLetter = (m) => statistics.DeadLetteredMessages++; client.OnConnected = () => { ulong areaId = Locator.GetAreaIdFromWorldPosition(location); _testCountdownEventStart.Signal(); _testCountdownEventStart.Wait(); statistics.MessageStatistic.Add("CREATE", RunStatistics(client, qos, "Create objects", MessageCount, _ => new ObjectCreateCommand(0, _, 0, 0, 0, location, AQuaternion.Zero))); _testCountdownEventCreated.Signal(); _testCountdownEventCreated.Wait(); statistics.MessageStatistic.Add("UPDATE", RunStatistics(client, qos, "Update positions", MessageCount, _ => new ObjectUpdatePositionCommand(_, location, AQuaternion.Zero, AVector3.Zero, AVector3.Zero, 0, 0))); _testCountdownEventUpdate.Signal(); _testCountdownEventUpdate.Wait(); //statistics.MessageStatistic.Add("DELETE", RunStatistics(client, qos, "Destroy objects", MessageCount, _ => new ObjectDestroyCommand(0, 0, locationX, locationY, locationZ))); _testCountdownEventDestroy.Signal(); _testCountdownEventDestroy.Wait(); statistics.UnackedMessages = client.ReliableMessaging.MessageUnackedCount; statistics.MessagesSent = client.ReliableMessaging.MessageSentCount; statistics.MessagesReceived = client.ReliableMessaging.MessageReceivedCount; statistics.ResentMessages = client.ReliableMessaging.MessageResentCount; eventFinished.Set(); }; eventFinished.WaitOne(); return(statistics); }); return(task); }