public void ObservationCreateCommandHandler_Handle()
        {
            var user = FakeObjects.TestUserWithId();
            var imageMediaResource = FakeObjects.TestImageMediaResourceWithId();
            var userProject        = FakeObjects.TestUserProjectWithId();
            var createdDateTime    = DateTime.UtcNow;

            Observation newValue = null;

            var command = new ObservationCreateCommand()
            {
                UserId    = user.Id,
                Address   = FakeValues.Address,
                Latitude  = FakeValues.Latitude,
                Longitude = FakeValues.Longitude,
                Media     = new List <Tuple <string, string, string> >()
                {
                    new Tuple <string, string, string>(imageMediaResource.Id, FakeValues.Message, FakeValues.Message)
                },
                Category   = FakeValues.Category,
                ObservedOn = createdDateTime,
                Title      = FakeValues.Title
            };

            using (var session = _store.OpenSession())
            {
                // for polymorphism: see http://ravendb.net/faq/polymorphism
                //_store.Conventions.CustomizeJsonSerializer = serializer => serializer.TypeNameHandling = TypeNameHandling.All;

                session.Store(user);
                session.Store(imageMediaResource);
                session.Store(userProject);
                session.SaveChanges();

                var commandHandler = new ObservationCreateCommandHandler(session);
                commandHandler.Handle(command);
                session.SaveChanges();

                newValue = session
                           .Query <Observation>()
                           .FirstOrDefault(x => x.ObservedOn == createdDateTime);
            }

            Assert.IsNotNull(newValue);
            Assert.AreEqual(command.Address, newValue.Address);
            Assert.AreEqual(command.Latitude, newValue.Latitude);
            Assert.AreEqual(command.Longitude, newValue.Longitude);
            Assert.AreEqual(command.Category, newValue.Category);
            Assert.AreEqual(command.ObservedOn, newValue.ObservedOn);
            Assert.AreEqual(command.Title, newValue.Title);
        }
        public void ObservationCreateCommandHandler_Handle()
        {
            var user = FakeObjects.TestUserWithId();
            var imageMediaResource = FakeObjects.TestImageMediaResourceWithId();
            var userProject = FakeObjects.TestUserProjectWithId();
            var createdDateTime = DateTime.UtcNow;

            Observation newValue = null;

            var command = new ObservationCreateCommand()
            {
                UserId = user.Id,
                Address = FakeValues.Address,
                Latitude = FakeValues.Latitude,
                Longitude = FakeValues.Longitude,
                Media = new List<Tuple<string,string,string>>(){new Tuple<string, string, string>(imageMediaResource.Id, FakeValues.Message,FakeValues.Message)},
                Category = FakeValues.Category,
                ObservedOn = createdDateTime,
                Title = FakeValues.Title
            };

            using (var session = _store.OpenSession())
            {
                // for polymorphism: see http://ravendb.net/faq/polymorphism
                //_store.Conventions.CustomizeJsonSerializer = serializer => serializer.TypeNameHandling = TypeNameHandling.All;

                session.Store(user);
                session.Store(imageMediaResource);
                session.Store(userProject);
                session.SaveChanges();

                var commandHandler = new ObservationCreateCommandHandler(session);
                commandHandler.Handle(command);
                session.SaveChanges();

                newValue = session
                    .Query<Observation>()
                    .FirstOrDefault(x => x.ObservedOn == createdDateTime);
            }

            Assert.IsNotNull(newValue);
            Assert.AreEqual(command.Address, newValue.Address);
            Assert.AreEqual(command.Latitude, newValue.Latitude);
            Assert.AreEqual(command.Longitude, newValue.Longitude);
            Assert.AreEqual(command.Category, newValue.Category);
            Assert.AreEqual(command.ObservedOn, newValue.ObservedOn);
            Assert.AreEqual(command.Title, newValue.Title);
        }