Exemplo n.º 1
0
Arquivo: Game.cs Projeto: danfma/NDB
 public Game(DateTime when, Sport sport, Team team1, Team team2)
 {
     _when = when;
     Sport = sport;
     Team1 = team1;
     Team2 = team2;
 }
        private static void Step2()
        {
            // Create instance
            var volleyball = new Sport("volley-ball");

            // Create 4 players
            var player1 = new Player("julia", DateTime.Now, volleyball);
            var player2 = new Player("magdalena", DateTime.Now, volleyball);
            var player3 = new Player("jacek", DateTime.Now, volleyball);
            var player4 = new Player("michal", DateTime.Now, volleyball);

            // Create two teams
            var team1 = new Team("Krakow");
            var team2 = new Team("Skawina");

            // Set players for team1
            team1.AddPlayer(player1);
            team1.AddPlayer(player2);

            // Set players for team2
            team2.AddPlayer(player3);
            team2.AddPlayer(player4);

            // Then create a volley ball game for the two teams
            var game = new Game(DateTime.Now, volleyball, team1, team2);

            using (var odb = OdbFactory.Open(TutorialDb5MinName))
                odb.Store(game);
        }
        private static void Step1()
        {
            var sport = new Sport("volley-ball");

            using (var odb = OdbFactory.Open(TutorialDb5MinName))
                odb.Store(sport);
        }
        public void TheSnippet()
        {
            //=================================

            // Create the instance be stored
            var sport = new Sport("volley-ball") {Value = "gold"};

            // Open the database
            using (var odb = OdbFactory.Open(DbName))
            {
                // Store the object
                odb.Store(sport);
            }

            //=================================

            // Open the database
            using (var odb = OdbFactory.Open(DbName))
            {
                var sports = odb.QueryAndExecute<Sport>();

                Assert.That(sports, Has.Count.EqualTo(1));
            }

            //=================================

            // Open the database
            using (var odb = OdbFactory.Open(DbName))
            {
                var firstSport = odb.QueryAndExecute<Sport>().GetFirst();

                firstSport.Value = "silver";
                odb.Store(firstSport);
            }

            //=================================

            //Open the database
            using (var odb = OdbFactory.Open(DbName))
            {
                var first = odb.QueryAndExecute<Sport>().GetFirst();
                odb.Delete(first);
            }

            // Open the database
            using (var odb = OdbFactory.Open(DbName))
            {
                var sports = odb.QueryAndExecute<Sport>();

                Assert.That(sports, Has.Count.EqualTo(0));
            }

            //=================================
        }
Exemplo n.º 5
0
Arquivo: Player.cs Projeto: danfma/NDB
 public Player(string name, DateTime birthDate, Sport favoriteSport)
 {
     Name = name;
     BirthDate = birthDate;
     FavoriteSport = favoriteSport;
 }
Exemplo n.º 6
0
 public Player(string name, DateTime birthDate, Sport favoriteSport)
 {
     Name          = name;
     BirthDate     = birthDate;
     FavoriteSport = favoriteSport;
 }