public void Add_Holes_And_Courseconfiguration_Then_Delete_And_Compare()
        {
            var hole1 = new Hole
            {
                Number      = 1,
                Par         = 3,
                Length      = 100,
                Description = "rakt med ob till höger"
            };

            var hole2 = new Hole
            {
                Number      = 2,
                Par         = 4,
                Length      = 153,
                Description = "dogleg vänster, mandatory passera trädet 35m fram på vänster sida"
            };

            var courseconfiguration = new Courseconfiguration
            {
                CourseName = "TestBanan"
            };

            courseconfiguration.AddHole(hole1);
            courseconfiguration.AddHole(hole2);

            Courseconfiguration dbCourseconfiguration;

            using (var session = NHibernateFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var id = session.Save(courseconfiguration);
                    dbCourseconfiguration = session.Get <Courseconfiguration>(id);
                    session.Delete(dbCourseconfiguration);
                    transaction.Commit();
                }
            }

            Assert.That(dbCourseconfiguration.Holes.Count == 2);
            Assert.AreEqual(courseconfiguration, dbCourseconfiguration);
        }
        public void Create_Tour_With_Competitions_And_Players()
        {
            var courseconfig = new Courseconfiguration
            {
                CourseMap   = "coursemap",
                CourseName  = "first",
                Description = "my first course"
            };

            courseconfig.AddHole(new Hole {
                Length = 100, Number = 1, Par = 3
            });
            courseconfig.AddHole(new Hole {
                Length = 86, Number = 2, Par = 3
            });
            courseconfig.AddHole(new Hole {
                Length = 149, Number = 3, Par = 4
            });

            var player1 = new Player
            {
                Email     = "*****@*****.**",
                FirstName = "firstname",
                LastName  = "lastname",
                Phone     = "08112233"
            };

            var player2 = new Player
            {
                Email     = "*****@*****.**",
                FirstName = "john",
                LastName  = "doe",
                Phone     = "08334422"
            };

            var competition = new Competition {
                Date = DateTime.UtcNow, Name = "dgt1"
            };

            competition.AddPlayer(new PlayerStatus {
                Player = player1, Status = PlayerCompetitionStatus.Registered
            });
            competition.AddPlayer(new PlayerStatus {
                Player = player2, Status = PlayerCompetitionStatus.Payed
            });

            competition.AddRound(new Round {
                Courseconfig = courseconfig, RoundNumber = 1
            });
            competition.AddRound(new Round {
                Courseconfig = courseconfig, RoundNumber = 2
            });

            var tour = new Tour {
                Year = "2015", Description = "testTour"
            };

            tour.AddCompetition(competition);

            Player dbPlayer1;
            Player dbPlayer2;
            Courseconfiguration dbCourseconfig;
            Tour dbTour;

            using (var session = NHibernateFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var pid1 = session.Save(player1);
                    var pid2 = session.Save(player2);
                    var cid  = session.Save(courseconfig);
                    var tid  = session.Save(tour);

                    dbPlayer1      = session.Get <Player>(pid1);
                    dbPlayer2      = session.Get <Player>(pid2);
                    dbCourseconfig = session.Get <Courseconfiguration>(cid);
                    dbTour         = session.Get <Tour>(tid);

                    session.Delete(dbPlayer1);
                    session.Delete(dbPlayer2);
                    session.Delete(dbCourseconfig);
                    session.Delete(dbTour);

                    transaction.Commit();
                }
            }

            Assert.AreEqual(player1, dbPlayer1);
            Assert.AreEqual(player2, dbPlayer2);
            Assert.AreEqual(courseconfig, dbCourseconfig);
            Assert.AreEqual(tour, dbTour);
        }