Exemplo n.º 1
0
        private static void TestFileSerialization()
        {
            BaseballRepo.UseFile = true;
            IBaseballRepo repo         = new BaseballRepo();
            var           cubs1984Team = repo.CreateTeam();

            PopulateCubs1984Team(repo, cubs1984Team);
            PrintSalaries(cubs1984Team);
            ThreadsafeConsole.WriteLine();
            ThreadsafeConsole.WriteLine();
            cubs1984Team.Save();
            ThreadsafeConsole.WriteLine("Saving team to JSON text file.");
            ThreadsafeConsole.WriteLine("Loading team from JSON text file.");
            ThreadsafeConsole.WriteLine();
            ThreadsafeConsole.WriteLine();
            cubs1984Team = repo.GetTeam(1);
            PrintSalaries(cubs1984Team);
            ThreadsafeConsole.WriteLine();
            ThreadsafeConsole.WriteLine();
            ThreadsafeConsole.WriteLine("Saving team to JSON text file.");
            LeagueRegulations.TeamSalaryCap = 40_000_000m;
            ThreadsafeConsole.WriteLine($"Changing team salary cap to {LeagueRegulations.TeamSalaryCap:C0}.");
            ThreadsafeConsole.WriteLine("Loading team from JSON text file.");
            ThreadsafeConsole.WriteLine();
            ThreadsafeConsole.WriteLine();
            cubs1984Team = repo.GetTeam(1);
            PrintSalaries(cubs1984Team);
        }
Exemplo n.º 2
0
        private static void TestSalaries()
        {
            IBaseballRepo repo         = new BaseballRepo();
            var           cubs1984Team = repo.CreateTeam();

            PopulateCubs1984Team(repo, cubs1984Team);
            PrintSalaries(cubs1984Team);
        }
Exemplo n.º 3
0
        private static void TestSalaryUpdate_23_7()
        {
            IBaseballRepo repo         = new BaseballRepo();
            var           cubs1984Team = repo.CreateTeam();

            PopulateCubs1984Team(repo, cubs1984Team);
            PrintSalaries(cubs1984Team);
            ThreadsafeConsole.WriteLine();
            ThreadsafeConsole.WriteLine();
            const decimal sandbergIncrease = 7_000_000m;
            const decimal davisIncrease    = 2_000_000m;

            // ReSharper disable PossibleNullReferenceException
            cubs1984Team.Players.First(Player => Player.JerseyNumber == 23).Salary += sandbergIncrease;
            cubs1984Team.Players.First(Player => Player.JerseyNumber == 07).Salary += davisIncrease;
            ThreadsafeConsole.WriteLine($"Increase Sandberg's salary by {sandbergIncrease:C0}");
            ThreadsafeConsole.WriteLine($"Increase Davis'     salary by {davisIncrease:C0}");
            ThreadsafeConsole.WriteLine();
            ThreadsafeConsole.WriteLine();
            // ReSharper restore PossibleNullReferenceException
            PrintSalaries(cubs1984Team);
        }