Beispiel #1
0
        private static void AssigneSwimmersToClubs(Registrant swimmer1, Registrant swimmer2, Registrant swimmer3, Club club1, Club club2)
        {
            Console.WriteLine("*******Adding swimmers to clubs ******\n***********************************");

            club1.AddSwimmer(swimmer1);
            DisplayInfo("club1", club1.ToString());
            DisplayInfo("swimmer1", swimmer1.ToString());

            club2.AddSwimmer(swimmer2);
            DisplayInfo("club2", club2.ToString());
            DisplayInfo("swimmer2", swimmer2.ToString());

            try
            {
                swimmer2.Club = club1;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                swimmer3.Club = club1;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            DisplayInfo("swimmer3", swimmer3.ToString());
            DisplayInfo("club1", club1.ToString());
        }
Beispiel #2
0
        private static void CreateSwimmers(out Registrant swimmer1, out Registrant swimmer2, out Registrant swimmer3)
        {
            swimmer1 = new Registrant("Bob Smith", new DateTime(1970, 1, 1),
                                      new Address("35 Elm St", "Toronto", "ON", "M2M 2M2"), 4161234567);
            DisplayInfo("swimmer1", swimmer1.ToString());

            swimmer2 = new Registrant();
            DisplayInfo("swimmer2", swimmer2.ToString());
            swimmer2.Address     = new Address("1 King St", "Toronto", "ON", "M2M 3M3");
            swimmer2.Name        = "John Lee";
            swimmer2.PhoneNumber = 4162222222;
            swimmer2.DateOfBirth = new DateTime(1950, 12, 1);
            DisplayInfo("swimmer2", swimmer2.ToString());

            swimmer3 = new Registrant("Ann Smith", new DateTime(1975, 1, 1),
                                      new Address("5 Queen St", "Toronto", "ON", "M2M 4M4"), 4163333333);
            DisplayInfo("swimmer3", swimmer3.ToString());
        }
        public void Test_Registrant_EmptyValues()
        {
            Registrant swimmer1       = new Registrant();
            string     expectedResult = $"Name: {swimmer1.Name}\nAddress: {swimmer1.Address.ToString()}\n" +
                                        $"Phone: {swimmer1.PhoneNumber}\nDOB: {swimmer1.DateOfBirth}\nReg number: {swimmer1.RegistrantId}\n" +
                                        $"Club: not assigned";

            Assert.AreEqual(expectedResult, swimmer1.ToString());
        }
        public void Test_Registrant_ToString()
        {
            Registrant swimmer1 = new Registrant("Bob Smith", new DateTime(1970, 1, 1),
                                                 new Address("35 Elm St", "Toronto", "ON", "M2M 2M2"), 4164588700);
            string expectedResult = $"Name: {swimmer1.Name}\nAddress: {swimmer1.Address.ToString()}\n" +
                                    $"Phone: {swimmer1.PhoneNumber}\nDOB: {swimmer1.DateOfBirth}\nReg number: {swimmer1.RegistrantId}\n" +
                                    $"Club: {(swimmer1.Club != null ? swimmer1.Club.Name : "not assigned")}";

            Assert.AreEqual(expectedResult, swimmer1.ToString());
        }