public void CommentCreateCommandHandler_Handle()
        {
            var user        = FakeObjects.TestUserWithId();
            var observation = FakeObjects.TestObservationWithId();

            Observation savedObservation = null;
            Comment     comment          = null;

            var command = new CommentCreateCommand()
            {
                Comment        = FakeValues.Comment,
                CommentedOn    = FakeValues.CreatedDateTime,
                ContributionId = observation.Id,
                UserId         = user.Id
            };

            //using (var session = _store.OpenSession(DocumentStoreHelper.TestDb))
            using (var session = _store.OpenSession())
            {
                session.Store(user);
                session.Store(observation);
                session.SaveChanges();

                var commandHandler = new CommentCreateCommandHandler(session);

                commandHandler.Handle(command);

                session.SaveChanges();

                savedObservation = session.Query <Observation>()
                                   .Where(x => x.Id == observation.Id)
                                   .FirstOrDefault();

                Assert.IsTrue(savedObservation.Comments.IsNotNullAndHasItems());

                comment = savedObservation.Comments.ToList()[0];
            }

            Assert.IsNotNull(comment);
            Assert.AreEqual(command.Comment, comment.Message);
            Assert.AreEqual(command.CommentedOn, comment.CommentedOn);
            Assert.AreEqual(command.UserId, comment.User.Id);
        }
        public void CommentCreateCommandHandler_Handle()
        {
            var user = FakeObjects.TestUserWithId();
            var observation = FakeObjects.TestObservationWithId();

            Observation savedObservation = null;
            Comment comment = null;

            var command = new CommentCreateCommand()
            {
                Comment = FakeValues.Comment,
                CommentedOn = FakeValues.CreatedDateTime,
                ContributionId = observation.Id,
                UserId = user.Id
            };

            //using (var session = _store.OpenSession(DocumentStoreHelper.TestDb))
            using (var session = _store.OpenSession())
            {
                session.Store(user);
                session.Store(observation);
                session.SaveChanges();

                var commandHandler = new CommentCreateCommandHandler(session);

                commandHandler.Handle(command);

                session.SaveChanges();

                savedObservation = session.Query<Observation>()
                    .Where(x => x.Id == observation.Id)
                    .FirstOrDefault();

                Assert.IsTrue(savedObservation.Comments.IsNotNullAndHasItems());

                comment = savedObservation.Comments.ToList()[0];
            }

            Assert.IsNotNull(comment);
            Assert.AreEqual(command.Comment, comment.Message);
            Assert.AreEqual(command.CommentedOn, comment.CommentedOn);
            Assert.AreEqual(command.UserId, comment.User.Id);
        }