public async Task UpdateShouldUpdateFields()
        {
            var user = new Traininglog {
                Id = _random.Next(), UserId = _currentUser.Id
            };

            _traininglogList.Add(user);

            var model = new UpdateTrainingLogModel
            {
                Date        = DateTime.Now,
                Description = _random.Next().ToString(),
                Rating      = _random.Next(),
                Comment     = _random.Next().ToString()
            };

            var result = await _query.Update(user.Id, model);

            result.Should().Be(user);
            result.Description.Should().Be(model.Description);
            result.Comment.Should().Be(model.Comment);
            result.Date.Should().BeCloseTo(model.Date);
            result.Rating.Should().Be(model.Rating);

            _uow.Verify(x => x.CommitAsync());
        }
        public void GetShouldThrowExceptionIfTrainingLogOfOtherUser()
        {
            var trainingLog = new Traininglog {
                Id = _random.Next(), UserId = _random.Next()
            };

            _traininglogList.Add(trainingLog);

            Action get = () => { _query.Get(trainingLog.Id); };

            get.Should().Throw <NotFoundException>();
        }
        public void GetShouldReturnById()
        {
            var trainingLog = new Traininglog {
                Id = _random.Next(), UserId = _currentUser.Id
            };

            _traininglogList.Add(trainingLog);

            var result = _query.Get(trainingLog.Id);

            result.Should().Be(trainingLog);
        }
        public void GetShouldThrowExceptionIfUserIsDeleted()
        {
            var trainingLog = new Traininglog {
                Id = _random.Next(), UserId = _currentUser.Id, IsDeleted = true
            };

            _traininglogList.Add(trainingLog);

            Action get = () => { _query.Get(trainingLog.Id); };

            get.Should().Throw <NotFoundException>();
        }
        public void DeleteShouldThrowExceptionIfItemIsNotBelongTheUser()
        {
            var expense = new Traininglog {
                Id = _random.Next(), UserId = _random.Next()
            };

            _traininglogList.Add(expense);

            Action execute = () =>
            {
                _query.Delete(expense.Id).Wait();
            };

            execute.Should().Throw <NotFoundException>();
        }
        public async Task DeleteShouldMarkAsDeleted()
        {
            var user = new Traininglog()
            {
                Id = _random.Next(), UserId = _currentUser.Id
            };

            _traininglogList.Add(user);

            await _query.Delete(user.Id);

            user.IsDeleted.Should().BeTrue();

            _uow.Verify(x => x.CommitAsync());
        }
        public void GetShouldThrowExceptionIfItemIsNotFoundById()
        {
            var trainingLog = new Traininglog {
                Id = _random.Next(), UserId = _currentUser.Id
            };

            _traininglogList.Add(trainingLog);

            Action get = () =>
            {
                _query.Get(_random.Next());
            };

            get.Should().Throw <NotFoundException>();
        }
        public async Task <Traininglog> Create(CreateTrainingLogModel model)
        {
            var trainingLog = new Traininglog
            {
                UserId      = _securityContext.User.Id,
                Date        = model.Date,
                Description = model.Description,
                Rating      = model.Rating,
                Comment     = model.Comment
            };

            _uow.Add(trainingLog);
            await _uow.CommitAsync();

            return(trainingLog);
        }