public async Task GetTransactionStatsOverMonth()
        {
            var receivings = new List <ObjectReceiving>
            {
                new ObjectReceiving
                {
                    ReceivedAtUtc = DateTime.UtcNow.Date.AddDays(-1)
                },
                new ObjectReceiving
                {
                    ReceivedAtUtc = DateTime.UtcNow.Date.AddDays(-1)
                },
                new ObjectReceiving
                {
                    ReceivedAtUtc = DateTime.UtcNow.Date.AddDays(-1)
                },
                new ObjectReceiving
                {
                    ReceivedAtUtc = DateTime.UtcNow.Date.AddDays(-30)
                },
                new ObjectReceiving
                {
                    ReceivedAtUtc = DateTime.UtcNow.Date.AddDays(-30)
                },
            };

            var receivingsRepo = new Mock <IRepository <Guid, ObjectReceiving> >();

            receivingsRepo.Setup(rc => rc.Table).Returns(receivings.AsQueryable());

            var statsGetter = new TransactionStatisticsGetter(null, receivingsRepo.Object);

            var result = await statsGetter.GetTransactionsCountOverMonth();

            Assert.IsTrue(result.Count == 31 && result[0].Count == 2 && result[29].Count == 3);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> StatsOverMonth()
        {
            var stats = await _statsGetter.GetTransactionsCountOverMonth();

            return(Ok(stats));
        }