Example #1
0
        private static Chart MessagesSentFromServerPrSecond(ChartPostModel model)
        {
            var testData = new TestData
            {
                StartTime = DateUtils.FromMillisecondsSinceEpoch(model.StartTime)
            };

            return testData.MessagesSentByServerPrSecond(model.Spacing, model.SentFromServerEvents.ToArray());
        }
Example #2
0
        private static Chart AverageLatency(ChartPostModel model)
        {
            var testData = new TestData
            {
                StartTime = DateUtils.FromMillisecondsSinceEpoch(model.StartTime)
            };

            return testData.AverageLatencyPrSecond(model.Spacing, model.TestDataEntities, model.SentFromClientEvents.ToArray());
        }
        public void Post_adds_MessagesSentServer_chart_to_repo_and_returns_status()
        {
            var model = new ChartPostModel
            {
                Type = "MessagesSentServer",
                StartTime = new DateTime().ToMilliseconds(),
                SentFromServerEvents = GetDummyDataSet(100, 300),
                Spacing = 10
            };

            _controller.Post(model).Should().Be("Calculation complete for chart " + model.Type);
        }
Example #4
0
        public string Post(ChartPostModel model)
        {
            switch (model.Type)
            {
                case "MessagesSentReceived":
                    ChartsRepo.Charts.Add(MessagesReceivedAtServerAndSentFromClientsPrSecond(model));
                    return "Calculation complete for chart: " + model.Type;
                case "MessagesSentServer":
                    ChartsRepo.Charts.Add(MessagesSentFromServerPrSecond(model));
                    return "Calculation complete for chart " + model.Type;
                case "AverageLatency":
                    ChartsRepo.Charts.Add(AverageLatency(model));
                    return "Calculation complete for chart " + model.Type;
            }

            return null;
        }
        public void Post_should_not_take_more_than_one_second_with_large_dataSets()
        {
            var model = new ChartPostModel
            {
                Type = "MessagesSentReceived",
                StartTime = new DateTime().ToMilliseconds(),
                ReceivedAtServerEvents = GetDummyDataSet(1000, 50),
                SentFromClientEvents = GetDummyDataSet(1000, 50),
                Spacing = 10
            };

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            _controller.Post(model);
            stopwatch.Stop();

            stopwatch.ElapsedMilliseconds.Should().BeLessOrEqualTo(1000);
        }
        public void Post_should_return_null_on_unknown_chart_type()
        {
            var model = new ChartPostModel
            {
                Type = "IfIFitsISits"
            };

            _controller.Post(model).Should().BeNull();
        }