Esempio n. 1
0
        public async Task GetTest()
        {
            var logger  = new Mock <ILogger <IpStatsController> >();
            var ipStats = new Mock <IIpReportService>();
            var cache   = new CacheForTest();

            ipStats.Setup(i => i.GetIpCallsStats()).ReturnsAsync(GetIpCallsStats());
            var controller = new IpStatsController(logger.Object, ipStats.Object, cache);

            var res = await controller.Get();

            Assert.AreEqual(2, res.ByCountry.Count());
        }
Esempio n. 2
0
        public async Task GetMathResultTest()
        {
            var logger  = new Mock <ILogger <IpStatsController> >();
            var ipStats = new Mock <IIpReportService>();
            var cache   = new CacheForTest();

            ipStats.Setup(i => i.GetIpCallsStats()).ReturnsAsync(GetIpCallsStats());
            var controller = new IpStatsController(logger.Object, ipStats.Object, cache);

            var res = await controller.Get();

            Assert.AreEqual(10283, res.MaxDistance);
            Assert.AreEqual(2824, res.MinDistance);
            Assert.AreEqual(((10283 * 5) + (2824 * 10)) / 15, res.AverageDistance);
        }