Пример #1
0
 public void CannotCreateSoccerPlayerWithEmptyName()
 {
     Assert.Catch(() =>
     {
         var x = new SoccerPlayer("", "");
     });
 }
Пример #2
0
        public void SoccerPlayerPositionReturnsSameValueAsSet()
        {
            var x = new SoccerPlayer("Test Player", "TestTeam");

            x.Position = "Test Position";
            Assert.IsTrue(x.Position == "Test Position");
        }
Пример #3
0
        public static void Run()
        {
            var source = new Subject <SoccerPlayer>();

            //subscribe on all Players from Team 1:
            source
            //.Sample(TimeSpan.FromSeconds(1.0))
            .Where(x => x.getTeam() == "Team 1")
            .Subscribe(x => Console.WriteLine($"received<- {x.getName()} {x.getTeam()}"))
            ;

            var t = new Thread(() =>
            {
                var i = 0;
                while (i < 10)
                {
                    Thread.Sleep(250);
                    SoccerPlayer s = new SoccerPlayer("Player " + i, "Team " + i % 3);
                    source.OnNext(s);
                    Console.WriteLine($"sent-> {s.getName()} {s.getTeam()}");
                    i++;
                }
            });

            t.Start();
        }
Пример #4
0
        static void Main(string[] args)
        {
            /*Taks 2*/
            SoccerPlayer origi = new SoccerPlayer("Divock Origi", "Liverpool U21");

            origi.Position = "Forward";
            Console.WriteLine(origi);
            origi.setTeam("Liverpool FC");
            origi.MarketValueM = 9;
            Console.WriteLine(origi);

            /*Task 3*/
            var athletes = new athlete[]
            {
                new SoccerPlayer("Gilbert Prilassnig", "SK Sturm Graz"),
                new SoccerPlayer("Dieter Ramusch", "GAK"),
                new TennisPlayer("Björn Borg"),
                new TennisPlayer("Yevgeny Kafelnikov")
            };

            foreach (var a in athletes)
            {
                Console.WriteLine(a.getDescription());
            }
            /*-------------*/
        }
Пример #5
0
 public void SoccerPlayerConnotSetNegativeMarketValue()
 {
     Assert.Catch(() =>
     {
         var x          = new SoccerPlayer("Test Player", "");
         x.MarketValueM = -1;
     });
 }
Пример #6
0
        static void Main(string[] args)
        {
            SoccerPlayer origi = new SoccerPlayer("Divock Origi", "Liverpool U21");

            origi.Position = "Forward";
            Console.WriteLine(origi);
            origi.setTeam("Liverpool FC");
            origi.MarketValueM = 9;
            Console.WriteLine(origi);
        }
Пример #7
0
        static void Main(string[] args)
        {
            /*Taks 2*/
            SoccerPlayer origi = new SoccerPlayer("Divock Origi", "Liverpool U21");

            origi.Position = "Forward";
            Console.WriteLine(origi);
            origi.setTeam("Liverpool FC");
            origi.MarketValueM = 9;
            Console.WriteLine(origi);

            /*Task 3*/
            var athletes = new athlete[]
            {
                new SoccerPlayer("Gilbert Prilassnig", "SK Sturm Graz"),
                new SoccerPlayer("Dieter Ramusch", "GAK"),
                new TennisPlayer("Björn Borg", "", 1),
                new TennisPlayer("Yevgeny Kafelnikov", "", 1)
            };

            foreach (var a in athletes)
            {
                Console.WriteLine(a.getDescription());
            }
            /*-------------*/

            /*---Task 4.3 JSON serial--------*/
            var players = new athlete[]
            {
                new GolfPlayer("Tiger Woods", "USA", 1),
                new GolfPlayer("Jordan Spieth", "NED", 2),
                new GolfPlayer("Happy Gilmore", "USA", 200),
                new TennisPlayer("Björn Borg", "", 1),
                new TennisPlayer("Yevgeny Kafelnikov", "", 1)
            };

            var settings = new JsonSerializerSettings()
            {
                Formatting = Formatting.Indented, TypeNameHandling = TypeNameHandling.Auto
            };

            string json = JsonConvert.SerializeObject(players, settings);

            Console.Write(json);
            System.IO.File.WriteAllText("players.json", json);

            string json2 = System.IO.File.ReadAllText("players.json");

            var players2 = JsonConvert.DeserializeObject <athlete[]> (json2, settings);

            Console.WriteLine(players2[0].getDescription());

            /*-----------*/
        }
Пример #8
0
        static void Main(string[] args)
        {
            /*Taks 2*/
            SoccerPlayer origi = new SoccerPlayer("Divock Origi", "Liverpool U21");

            origi.Position = "Forward";
            Console.WriteLine(origi);
            origi.setTeam("Liverpool FC");
            origi.MarketValueM = 9;
            Console.WriteLine(origi);

            /*Task 3*/
            var athletes = new athlete[]
            {
                new SoccerPlayer("Gilbert Prilassnig", "SK Sturm Graz"),
                new SoccerPlayer("Dieter Ramusch", "GAK"),
                new TennisPlayer("Björn Borg", "", 1),
                new TennisPlayer("Yevgeny Kafelnikov", "", 1)
            };

            foreach (var a in athletes)
            {
                Console.WriteLine(a.getDescription());
            }
            /*-------------*/

            /*---Task 4.3 JSON serial--------*/
            var players = new athlete[]
            {
                new GolfPlayer("Tiger Woods", "USA", 1),
                new GolfPlayer("Jordan Spieth", "NED", 2),
                new GolfPlayer("Happy Gilmore", "USA", 200),
                new TennisPlayer("Björn Borg", "", 1),
                new TennisPlayer("Yevgeny Kafelnikov", "", 1)
            };

            var settings = new JsonSerializerSettings()
            {
                Formatting = Formatting.Indented, TypeNameHandling = TypeNameHandling.Auto
            };

            string json = JsonConvert.SerializeObject(players, settings);

            Console.Write(json);
            System.IO.File.WriteAllText("players.json", json);

            string json2 = System.IO.File.ReadAllText("players.json");

            var players2 = JsonConvert.DeserializeObject <athlete[]> (json2, settings);

            Console.WriteLine(players2[0].getDescription());

            /*-----------*/

            /*----Task6.2--Experiment with tasks--*/
            Task <int> callback = Task.Run(() =>
            {
                Thread.Sleep(2000);
                return(42);
            });

            //Console.WriteLine(futureInt.Result); //blockierend

            var f2 = callback.ContinueWith(x => Console.WriteLine("callback executed: " + x.Result));

            var cnt = 0;

            while (cnt++ < 6)
            {
                Console.WriteLine("do something else...");
                Thread.Sleep(500);
            }
            /*-------------- */

            /*----Task 6.1--Pushing/Subscribe with query---*/
            Console.WriteLine();
            pushWithSubject.Run();
            /*------------*/
        }
Пример #9
0
        public void SoccerPlayerDescriptionIsCorrect()
        {
            var x = new SoccerPlayer("Test Player", "");

            Assert.IsTrue(x.getDescription() == "Test Player, SoccerPlayer");
        }
Пример #10
0
        public void SoccerPlayerNameReturnsSameValueUsedForInitialization()
        {
            var x = new SoccerPlayer("Test Player", "TestTeam");

            Assert.IsTrue(x.getName() == "Test Player");
        }