public void AddData_BasicCorrect_AddsToDatabase()
        {
            Mock<IDatabaseContext> fakeContext = new Mock<IDatabaseContext>();
            var manager = Resolve(fakeContext);

            Guid key = Guid.NewGuid();
            int groupId = 100;
            fakeContext.Setup(x => x.List<ApiKey>())
                .Returns(new[]
                {
                    new ApiKey
                    {
                        Key = key,
                        AccountGroupId = groupId,
                        IsActive = true,
                        ValidUpTo = DateTime.MaxValue,
                        AccountGroup = new AccountGroup { Id = 222, }
                    }
                }.AsQueryable());
            IMetricParameters par = new MetricParameters(key);
            manager.AddData(par);

            fakeContext.Verify(x => x.Add(It.Is<ReceivedEvent>(y => y.ReceivedDate.Date == DateTime.Today
                && y.GroupId == groupId
                && y.JsonData == par.AsData
                && y.ProcessedTime == null)));
            fakeContext.Verify(x => x.SaveChanges());
        }
        public void AddData_BadValidationDate_NoSave()
        {
            Mock<IDatabaseContext> fakeContext = new Mock<IDatabaseContext>();
            var manager = Resolve(fakeContext);

            Guid key = Guid.NewGuid();
            int groupId = 100;
            fakeContext.Setup(x => x.List<ApiKey>())
                .Returns(new[]
                {
                    new ApiKey
                    {
                        Key = key,
                        AccountGroupId = groupId,
                        IsActive = true,
                        ValidUpTo = DateTime.Today,
                    }
                }.AsQueryable());

            IMetricParameters par = new MetricParameters(key);
            manager.AddData(par);
        }
        public void AddData_NoKey_ThrowsException()
        {
            Mock<IDatabaseContext> fakeContext = new Mock<IDatabaseContext>();
            var manager = Resolve(fakeContext);

            IMetricParameters par = new MetricParameters(Guid.NewGuid());
            manager.AddData(par);
        }