public virtual void Entities_with_identity_generated_ids_gets_assigned_id_written_to_id_property_after_insert()
        {
            var movie1 = new Movie
                {
                    Title = "Movie 1",
                    ReleaseDate = new DateTime(2012, 1, 2)
                };

            var movie2 = new Movie
                {
                    Title = "Movie 2",
                    ReleaseDate = new DateTime(2012, 1, 2)
                };

            var movie3 = new Movie
                {
                    Title = "Movie 3",
                    ReleaseDate = new DateTime(2012, 1, 2)
                };

            Repository.Insert(movie1);
            Repository.Insert(movie2, movie3);

            var allMovies = Repository.Find<Movie>().OrderBy(x => x.Title).ExecuteList();

            Assert.AreEqual(3, allMovies.Count);
            Assert.AreEqual(allMovies[0].Id, movie1.Id);
            Assert.AreEqual(allMovies[1].Id, movie2.Id);
            Assert.AreEqual(allMovies[2].Id, movie3.Id);
        }
        public void Not_operator_can_be_used_to_filter_result()
        {
            var movie1 = new Movie
                {
                    Title = "Movie 1",
                    ReleaseDate = new DateTime(2012, 1, 2)
                };

            var movie2 = new Movie
                {
                    Title = "Movie 2",
                    ReleaseDate = new DateTime(2012, 1, 3)
                };

            var movie2_2 = new Movie
                {
                    Title = "Movie 2",
                    ReleaseDate = new DateTime(2012, 1, 2)
                };

            var movie3 = new Movie
                {
                    Title = "Movie 3",
                    ReleaseDate = new DateTime(2012, 1, 3)
                };

            Repository.Insert(movie1, movie2, movie2_2, movie3);

            var allMovies = Repository.Find<Movie>()
                                      .Where(x => !(x.Title == "Movie 2" && x.ReleaseDate == new DateTime(2012, 1, 2)))
                                      .OrderBy(x => x.Title)
                                      .ExecuteList();

            Assert.AreEqual(3, allMovies.Count);
            Assert.AreEqual(allMovies[0].Id, movie1.Id);
            Assert.AreEqual(allMovies[1].Id, movie2.Id);
            Assert.AreEqual(allMovies[2].Id, movie3.Id);
        }
        public virtual void Default_convention_only_maps_non_static_public_read_write_properties()
        {
            Repository.DefaultConvention = new DefaultConvention();

            var movie = new Movie
                {
                    Title = "Movie title",
                    ReleaseDate = new DateTime(2012, 01, 18)
                };

            movie.SetRating(4);

            Repository.Insert(movie);

            var actualMovie = Repository.Find<Movie>().Where(x => x.Title == "Movie title").Execute();

            Assert.AreEqual(movie.Title, actualMovie.Title);
            Assert.AreEqual(movie.ReleaseDate, actualMovie.ReleaseDate);
            Assert.AreEqual(0, actualMovie.Rating); // should not be mapped
        }
        public void Enum_values_are_stored_as_integers()
        {
            var movie = new Movie
                {
                    Title = "Movie 1",
                    ReleaseDate = new DateTime(2012, 1, 2),
                    Genre = MovieGenre.Comedy
                };

            Repository.Insert(movie);

            var actualMovie = Repository.Find<Movie>()
                                        .Where(x => x.Id == movie.Id)
                                        .Execute();

            movie.Genre = MovieGenre.SciFi;

            Repository.Update(movie);

            var actualMovieAfterFirstUpdate = Repository.Find<Movie>()
                                                        .Where(x => x.Id == movie.Id)
                                                        .Execute();

            Repository.Update<Movie>()
                      .Set(x => x.Genre, MovieGenre.Drama)
                      .Where(x => x.Genre == MovieGenre.SciFi)
                      .Execute();

            var actualMovieAfterSecondUpdate = Repository.Find<Movie>()
                                                         .Where(x => x.Id == movie.Id)
                                                         .Execute();

            Repository.Delete<Movie>().Where(x => x.Genre == MovieGenre.Drama).Execute();

            var actualMovieAfterDelete = Repository.Find<Movie>()
                                                   .Where(x => x.Id == movie.Id)
                                                   .Execute();

            Assert.AreEqual(MovieGenre.Comedy, actualMovie.Genre);
            Assert.AreEqual(MovieGenre.SciFi, actualMovieAfterFirstUpdate.Genre);
            Assert.AreEqual(MovieGenre.Drama, actualMovieAfterSecondUpdate.Genre);
            Assert.IsNull(actualMovieAfterDelete);
        }